#include<bits/stdc++.h>
using namespace std;
long long a,b,g,n,h;
bool check(int x)
{
if(x == 2) return 1;
for(int i = 2; i <= sqrt(x); i++)
if(x % i == 0) return false;
return true;
}
bool hws(int 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;
for(int i=a;i<=b;i+=2)
{
if(check(i)&& hws(i)) cout<<i<<endl;
}
return 0;
}
22分,求调。