P1217 [USACO1.5] Prime Palindromes

Description

Since $151$ is both a prime and a palindrome (it reads the same from left to right and from right to left), $151$ is a palindromic prime. Write a program to find all palindromic primes in the range $[a, b]$ with $5 \le a < b \le 100,000,000$ (one hundred million).

Input Format

The first line contains two positive integers $a$ and $b$.

Output Format

Output a list of palindromic primes, one per line.

Explanation/Hint

Hint 1: Generate palindromes and then check whether they are prime (also called “primes” or “sùshù” in pinyin). Hint 2: Generate palindromes by combining digits properly. You might need several loops like the one below. Problem translation from NOCOW. USACO Training Section 1.5. Generating palindromes of length $5$: ```cpp for (d1 = 1; d1