#include <bits/stdc++.h>
using namespace std;
int po(int x1,int x2)
{
if (x2==0)
return 1;
return pow(x1,x2-1)*x1;
}
bool pr(int x)
{
for (int z=0;z<sqrt(x)+1;z++)
if (x%z==0)
return 0;
return 1;
}
bool hw(int y)
{
int a[100],b[100],y1=0,p=0;
while (y)
{
a[p]=y%10;
y/=10;
p++;
}
for (int q=0;q<p;q++)
b[p-q]=a[q];
for (int h=p;h>=0;h--)
y1+=b[h]*po(10,h);
return y1;
}
int a,b;
int main()
{
cin>>a>>b;
for (int i=a;i<=b;i++)
if (pr(i) && hw(i))
cout<<i<<endl;
return 0;
}