#include <bits/stdc++.h>
using namespace std;
bool ikun(int n)
{
for(int i=2;i<=sqrt(n);i++)
{
if(n%i==0)
{
return false;
}
}
return true;
}
bool man(int n)
{
int t=n,k=n,tk[10005],tt=1;
while(t!=0)
{
tk[tt++]=t%10;
t/=10;
}
int x=0;
for(int i=0;i<tt;i++)
{
if(tk[x]==tk[tt-i])
{
x++;
}
else
{
return false;
}
}
return true;
}
int main()
{
int x,y;
cin >> x >> y;
for(int i=x;i<=y;i++)
{
if(man(i) && ikun(i))
{
cout << i << endl;
}
}
return 0;
}