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