cho.sh
Notes
Loading...

Prime Palindromes

Time limit

1s

Memory limit

256 MB

Problem

151 is a prime palindrome because it is prime and reads the same from left to right and from right to left. A palindrome is a number whose digits are unchanged when read in reverse. The number 1234 becomes 4321 when read backward, so it is not a palindrome.

Given two integers a and b, find every prime palindrome from a through b, inclusive.

Input

The first line contains two natural numbers a and b separated by a space.

The limits are 5 ≤ a < b ≤ 100,000,000.

Output

Print the prime palindromes from a through b in increasing order, one per line.

After printing all such numbers, print -1 on the final line.