#include <bits/stdc++.h>
using namespace std;
bool zhishu(int zs){
for(int i=2;i<=sqrt(zs);i++){
if(zs%i==0){
return 0;
}
}
if(zs>1){
return 1;
}
}
bool huiwenshu(int hws){
int h=0,y=hws;
while(hws){
h=h*10+hws%10;
hws=hws/10;
}
if(h==y){
h=0;
return 1;
}
h=0;
return 0;
}
int main(){
int a,b;
cin>>a>>b;
for(int j=a;j<=b;j++){
if(zhishu(j)==1&&huiwenshu(j)==1){
cout<<j<<"\n";
}
}
return 0;
}