#t127. 绝对素数

绝对素数

Absolute Prime

Problem Description

If a two-digit number is prime, and remains prime after swapping its two digits, it is called an absolute prime, for example 1313. Given two positive integers A,BA, B, find all absolute primes that are greater than or equal to AA and less than or equal to BB.

Input Format

The input is 11 line containing two positive integers AA and BB. It is guaranteed that 10<A<B<10010 < A < B < 100.

Output Format

Several lines, each containing one absolute prime, output in ascending order.

Sample Input

11 20

Sample Output

11
13
17

Sample Explanation

For the input A=11A = 11, B=20B = 20, the two-digit numbers in the range [11,20][11, 20] are 11,12,13,14,15,16,17,18,19,2011, 12, 13, 14, 15, 16, 17, 18, 19, 20. Among them the primes are 11,13,17,1911, 13, 17, 19. Check whether each is an absolute prime:

  • 1111 is prime, and reversed it is still 1111 (prime), so 1111 is an absolute prime.
  • 1313 is prime, and reversed it is 3131 (prime), so 1313 is an absolute prime.
  • 1717 is prime, and reversed it is 7171 (prime), so 1717 is an absolute prime.
  • 1919 is prime, and reversed it is 9191, but 91=7×1391 = 7 \times 13 is not prime, so 1919 is not an absolute prime.

Therefore the final output is 11,13,1711, 13, 17.

Constraints

10<A<B<10010 < A < B < 100, i.e. all numbers involved are two-digit numbers. It is guaranteed that A,BA, B and the primes sought are all within [10,99][10, 99].