#include<bits/stdc++.h>
using namespace std;
int l,r;
bool p(int n){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
bool f(int n){
int m=0,t=n;
while(t!=0){
m*=10;
m+=t%10;
t/=10;
}
if(m==n){
return true;
}
else{
return false;
}
}
int main(){
cin>>l>>r;
for(int i=l;i<=r;i++){
if(p(i)&&f(i)){
cout<<i<<"\n";
}
}
return 0;
}