put=input().split() for i in range(int(put[0]),int(put[1])+1): if str(i)[0:]==str(i)[-1::-1]: for s in range(2,i): if i%s==0: break else: print(i)