#include<bits/stdc++.h>
using namespace std;
int zh(int i){
for(int j=2;j<i;j++){
if(i%j==0){
return 0;
}
}
return 1;
}
int h(int i){
int a=i,b=0;
while(i!=0){
b=b*10+i%10;
i/=10;
}
if(a==b){
return 1;
}
return 0;
}
int main(){
int a,b=0,c=1,n,m;
cin>>n>>m;
for(int i=n;i<=m;i++){
if(zh(i)&&h(i)){
cout<<i<<endl;
}
}
return 0;
}