#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int ok(int n)
{
if (n % 2 == 0)
return 0;
int hh = 0, o = n, temp;
while (n > 0)
{
temp = n % 10;
hh = hh * 10 + temp;
n /= 10;
}
if (o != hh)
return 0;
int ss = sqrt(o);
for (int d = 3; d <= ss; d += 2)
{
if (o % d == 0)
return 0;
}
return 1;
}
int main()
{
int a, b;
int count = 0;
scanf("%d %d", &a, &b);
int *hhss = (int *)malloc((b - a) * sizeof(int));
for (int i = a; i < b; i++)
{
if (ok(i))
{
printf("%d\n", i);
hhss[count++] = i;
}
}
free(hhss);
return 0;
}