ZOJ Problem Set - 3014
Recently, DD found that 9875321 was a very special number, and it has three properties:
(1) 9875321 is a prime number.
(2) reverse it, we get 1235789, which is also a prime number.
(3) the digits of 9875321 are in strictly descreasing order.
Above all, for all the decimal numbers with the three properties, 9875321 is the maximal one. So we say 9875321 is very special.
Now, given N (2<=N<=16), find the N-based very special number. For N>10, we use capitals 'A', 'B', 'C'...
Each line of input is a test case, which consists of only one number N.
For each line of input you will output only one line for the N-band very special number. If the N-band very special number doesn't exist, output "not special".
Author: CUI, Tianyi
Source: ZOJ Monthly, August 2008