#include<bits/stdc++.h>
using namespace std;
int xs(int x)
{
long long y = 0,z = x;
while(z > 0)
{
y = (z % 10) + y * 10 ;
z /= 10;
}
if(y == x) return 1;
else return 0;
}
bool iPme(int x)
{
if(x == 0 || x == 1 || x == 4) return 0;
for(int i = 2;i * i <= x;i++)
{
if(x % i == 0)return 0;
}
return 1;
}
int main()
{
long long a,b;
cin>>a>>b;
for(int i = a;i <= b;i++)
{
if(xs(i) == 1)
{
if(iPme(i) == 1) cout<<i<<endl;
}
}
return 0;
}