#include<bits/stdc++.h>
using namespace std;
int a, b;
int fan(int x) {
int y = 0 ;
while(x != 0) {
y = y * 10 + x % 10;
x = x / 10;
}
return y;
}
bool calc(int x) {
int y = fan(x);
if(x < 2 || y < 2 || y != x)
return false;
for(int i = 2; i <= sqrt(y); i++) {
if(x % i == 0 && y % i == 0)
return false;
}
return true;
}
int main(){
scanf("%d%d", &a, &b);
for(int i = a; i <= b; i++){
if(calc(i))
printf("%d\n", i);
}
}