eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

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.

Лимит времени 0.5 секунд
Лимит использования памяти 256 MiB
Входные данные #1
1
Выходные данные #1
13
Источник ACM-ICPC Ukraine 2015, 2nd Stage Ukraine, Saturday, September 12, 2015