#include <bits/stdc++.h>
using namespace std;
int a,b;
bool isprime(int x)
{
for(int i=2;i*i<=x;i++)
{
if(x%i==0)
{
return false;
}
}
return true;
}
bool ispn(int n)
{
int x=0,s=n;
while(s>0)
{
x=x*10+s%10;
s/=10;
}
if(x==n)
{
return true;
}else
{
return false;
}
}
int main()
{
cin>>a>>b;
for(int i=a;i<=b;i++)
{
if(i%2==0)
{
continue;
}else if(isprime(i)&&ispn(i))
{
cout<<i<<endl;
}
}
return 0;
}