Lucky Primes
Easy
Execution time limit is 0.5 seconds
Runtime memory usage limit is 256 megabytes
Stefan calls an positive integer p lucky prime, if p and number p[1]
, 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.
####InputFirst line of the input contains one integer K (1 ≤ K ≤ 1000).
####OutputIf K -th lucky prime is not greater than 10^6
, print it. Otherwise print - 1.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 27%