import java.util.Scanner;
public class Main {
private static Scanner cin;
public static void main(String args[]) throws Exception {
cin = new Scanner(System.in);
int a = cin.nextInt();
int b = cin.nextInt();
for (int i=a; i<=b; i++) {
//如果可以被2、3、5整除,必然不满足条件
if(i!= 2 && i!=3 && i!=5 && (i%2==0 || i%3==0 || i%5==0)) {
continue;
}
if(isPalindrome(i)) {
if(isPrime(i)) {
System.out.println(i);
}
}
}
}
public static boolean isPalindrome(int n) {
int x = n;
int y = 0;
boolean ret = false;
while(x!=0) {
y = y*10 + x%10;
x = x/10;
}
if(y == n) {
ret = true;
}
return ret;
}
public static boolean isPrime(int n) {
boolean ret = true;
if ( n == 1 || n == 2 || n == 3) {
ret = true;
}else {
for(int i = 2; i<=Math.sqrt(n);i++) {
if(n%i == 0){
ret = false;
break;
}
}
}
return ret;
}
}