#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline bool isPrime(LL x){
if(x<2) return false;
for(LL i=2;i*i<=x;i++){
if(x%i==0) return false;
}
return true;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
LL a,b;
cin>>a>>b;
for(LL i=a;i<=b;i++){
string s=to_string(i);
string t=s;
reverse(s.begin(),s.end());
if((isPrime(i))&&(s==t)){
cout<<i<<endl;
}
}
return 0;
}