#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e7 + 7;
bool huiwen(int x){
int ans = 0;
for(int i = x; i > 0; i /= 10){
ans = ans * 10 + i % 10;
}
return ans == x;
}
int l, r;
bool a[N];
signed main(){
cin >> l >> r;
a[1] = 1;
for(int i = 2; i * i <= r; i ++){
if(a[i] == 0){
for(int j = i + i; j <= r; j += i)
a[j] = 1;
}
}
for(int i = l; i <= r; i ++){
if(huiwen(i) && a[i] == 0) cout << i << "\n";
}
return 0;
}
玄1关