#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
bool sh(int x){
if(x<2){
return 0;
}
else{
for(int i=2;i<x;i++){
if(x%i==0){
return 0;
}
}
}
return 1;
}
int main(){
int n,m;
cin>>n>>m;
for(int i=n;i<m;i++){
if(sh(i)==1){
string t;
t=to_string(i);
if(reverse(t.begin(),t.end())==t){
cout<<i<<' ';
}
}
}
return 0;
}