#include<bits/stdc++.h>
using namespace std;
int zhi(int x){
if(x<=1) return 0;
for(int i=2;i<=x/i;i++){
if(x%i==0) return 0;
}
return 1;
}
int hui(int x){
int s=0,y=x;
while(y){
int t=y%10;
y/=10;
s=s*10+t;
}
if(s==x) return 1;
else return 0;
}
int main(){
int a,b;
cin>>a>>b;
for(int i=a;i<=b;i++){
if(zhi(i)==1&&hui(i)==1) cout<<i<<endl;
}
return 0;
}