#include<stdio.h>
#include<math.h>
int main()
{
int i=0,m,n,a[100000],k,t=0,s=0,h;
scanf_s("%d%d", &m, &n);
for (m; m < n; m++)
{
k = m;
int b[10],x=0,y=0,z=0;
for (k; k > 0; k /= 10)
{
b[x] = k% 10;
x++;
}
for (x; x > 0; x--)
{
y = y + b[z] *(int) pow(10, x - 1);
z++;
}
if (y == m&&(y/2==(y-1)/2))
{
a[t] = y;
t++;
}
}
for (s; s <= t; s++)
{
for (h = 2; h < a[s]; h++)
{
if (a[s]% h == 0)break;
}
if (a[s] == h)printf("%d\n", a[s]);
}
return 0;
}