A - Deletable Primes

 

Problem

 

A deletable prime is a prime such that you can delete the digits one at a time, in some order, and get a prime at each step. For instance, the number 4125673 is a deletable prime, since all numbers in the sequence:

 

4125673

415673

45673

4567

467

67

7

 

are also (deletable) primes.

Our objective is to print the largest deletable prime in a given range.

 

Input

The input will consist of a series of pairs of positive integers i and j, one pair of integers per line. All integers will be less than 10,000,000. You can assume that i is lesser or equal than j. You should process all pairs of integers, and for each pair determine the largest deletable prime between i and j, inclusive. Input is terminated by a line with the number -1.

 

Output

For each pair of input integers, defining a range, you should output the largest deletable prime in the range, or none if no deletable primes exist in the range.

 

Sample Input

1 100

1000 1010

4125673 4125673

1 9999999

-1

 

Sample Output

97

none

4125673

9999907