Lucky Primes#7427

Lucky Primes

0.5 seconds
256 megabytes
Easy

Stefan calls a positive integer lucky prime, if 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 and itself.

Given , find -th lucky prime.

Input

First line of the input contains one integer (1 \leq K \leq 1000).

Output

If -th lucky prime is not greater than 10^6, print it. Otherwise print .

Examples

Example 1

Loading
Loading