DongStarry @ 2023-12-21 21:37:15
#include<bits/stdc++.h>
using namespace std;
bool a[17400001]={1,1};
long long n,m,cnt,b[17400001];
int main()
{
cin>>m>>n;
for(int i=2;i<=n;i++)
{
if(a[i]==0)
b[++cnt]=i;
for(int j=1;j<=cnt;j++)
{
if(i*b[j]>n)
break;
a[i*b[j]]=1;
if(i%b[j]==0)
break;
}
}
for(int i=1;i<=cnt;i++)
{
if(b[i]<m)
continue;
else
{
int e[11],z=0,x=0,p=b[i];
while(p>0)
{
e[z]=p%10;
p/=10;
z++;
}
if(z>2&&z%2==0)
continue;
for(int l=0,j=z-1; l<=j; l++,j--)
if(e[l]!=e[j])
x=1;
if(x==0)
cout<<b[i]<<endl;
}
}
return 0;
}