#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,f;
scanf("%lld %lld",&a,&b);
if(a%2==0) a++;
for(int i=a;i<=b;i+=2)
{
f=1;
if(i%2==0) continue;
for(int j=2;j<=sqrt(i);j++)
{
if(i%j==0)
{
f=0;
break;
}
}
if(f==1)
{
int s=0,x=i;
while(x!=0)
{
s=s*10+x%10;
x=x/10;
}
if(s==i) printf("%d\n",i);
}
}
return 0;
}