#include<bits/stdc++.h>
using namespace std;
long long a,b,g,n,h;
bool check(long long x)
{
if(x == 2) return 1;
for(long long i = 2; i <= sqrt(x); i++)
if(x % i == 0) return false;
return true;
}
bool hws(long long num) {
int temp=num,ans=0;
while (temp!=0) {
ans=ans*10+temp%10;
temp/=10;
}
if (ans==num)
return true;
else
return false;
}
int main(){
cin>>a>>b;
if(a%2==0)a++;
for(long long i=a;i<=b;i+=2)
{
if(b>=9999999) b=9999999;
if(check(i)&& hws(i)) cout<<i<<endl;
}
return 0;
}
66分,求调。