#B2139. Finding True Primes Between Two Numbers

    ID: 11221 Type: Default 1000ms 256MiB

Finding True Primes Between Two Numbers

Finding True Primes Between Two Numbers

Given two positive integers \(M\) and \(N\) (with \(N \ge M\)), find all true primes between them.

A true prime is defined as follows: if a positive integer \(P\) is a prime and the integer formed by reversing its digits is also a prime, then \(P\) is a true prime. For example, \(11\) is a true prime because its reverse is \(11\), and \(13\) is a true prime because its reverse, \(31\), is also prime.

inputFormat

The input consists of two positive integers \(M\) and \(N\) separated by space or newline, where \(N \ge M\).

outputFormat

Output all the true primes between \(M\) and \(N\) (inclusive), separated by a single space. If there are no such numbers, output nothing.

sample

10 100
11 13 17 31 37 71 73 79 97

</p>