from math import sqrt
def huiwen(num):
temp=num
total=0
while temp>0:
total=total * 10+temp % 10
temp//=10
if num==total:
return num
def prime(num):
for i in range(2,int(sqrt(num)+1)):
if num%i==0:
return False
return num if num!=1 else False
n=int(input())
ge_num=0
for i in range(2,10000):
if (huiwen(i) and prime(i)):
print(i,end=' ')
ge_num+=1
if ge_num==n:
break