f=lambda n:min(n%i for i in range(2,n)) j=9 while j<999:k=int(str(j)[::-1]);f(j)*f(k)*(j!=k)and print(j);j+=2