#include
using namespace std;
int su(int m){
if(m%2==0&&m>2)return 0;
int i;
for(i=3;i*i<=m;i+=2){
if(m%i==0)return 0;
}
return m>1;
}
int main(){
int m,n,M,x;
cin>>m>>n;
for(;m<=n;m++){
if(su(m)){
x=m;
M=0;
while(x){
M=M*10+x%10;
x=x/10;
}
if(M==m)
cout<if(m==11)m=99;
else if(m==99)m+=200;
else if(m==999)m+=9000;
else if(m==99999)m+=900000;
}
}
return 0;
}