#include<iostream>
#include<cmath>
using namespace std;
bool pd(int x){
for(int i=2;i<=sqrt(x);i++){
if(x%i==0)return false;
}
return true;
}
bool pd1(int x){
int temp=x,ans=0;
while (temp!=0) {
ans=ans*10+temp%10;
temp/=10;
}
if (ans==x)
return true;
else
return false;
}
int main(){
int a,b;
scanf("%d%d",&a,&b);
for(int i=a;i<=b;i++){
if(pd1(i)&&pd(i))printf("%d\n",i);
}
return 0;
}