Problems
L. Lucky Primes
L. Lucky Primes
Stefan calls an positive integer p lucky prime, if p and number p1
, obtained by reversing its decimal notation, i.e. reading all digits from end to beginning, are distinct primes.
Remind that positive integer is prime, if it has no positive integer divisors except for 1 and itself.
Given K , find K -th lucky prime.
Input
First line of the input contains one integer K (1 ≤ K ≤ 1000).
Output
If K -th lucky prime is not greater than 106
, print it. Otherwise print - 1.
Input example #1
1
Output example #1
13