# Abracadabra!

**Number Theory**Level 4

Mathia, the great magician, showed his audiences 9 cards, each displaying a distinct digit from 1 to 9 (inclusive), before putting 3 cards to each of his 3 top hats.

Afterwards, by yelling "Abracadabra!", the card "\(a\)" popped up magically from the first hat, where \(a\) was prime. Then with the second "Abracadabra!", the card "\(b\)" popped up from the second hat, and when he put it next to the previous card, the 2-digit number \(\overline{ab}\) was also prime. Then after calling out the third card "\(c\)", the 3-digit \(\overline{abc}\) was also prime and is the sum of \(\overline{ab}\) and a cube.

After a long applause, the magician began the second round of incantations in the same fashion. This time, the card "\(d\)" was a composite number. The 2-digit number \(\overline{de}\) was also a composite number, and the 3-digit number \(\overline{def}\) was composite and a difference between two squares, both greater than \(1\).

Last but not least, the grand finale started with the card "\(g\)" being a perfect square. The 2-digit number \(\overline{gh}\) was also a perfect square, and the 3-digit number \(\overline{ghi}\) was a sum of two different squares.

By revealing all the 9 cards, what is the value of the 9-digit number \(\overline{abcdefghi}\)? O