program sas;
var
a:array[1..30000] of longint;
b,c:array[1..6]of integer;
i,j,m,n,max:longint;
procedure ff(x:longint);
var i:longint;
begin
max:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then max:=1;
end;
procedure ss(x,z:longint);
var i:longint;
begin
ff(x);
if (max=0)and(z=n) then begin m:=m+1; a[m]:=x; end;
if (max=0)and(z<n) then
for i:=1 to 4 do
ss(x*10+c[i],z+1);
end;
begin
assign(input,'sprime.in');
reset(input);
assign(output,'sprime.out');
rewrite(output);
b[1]:=2;b[2]:=3;b[3]:=5;b[4]:=7;
c[1]:=1;c[2]:=3;c[3]:=7;c[4]:=9;
read(n);
for i:=1 to 4 do
ss(b[i],1);
for i:=1 to m do
writeln(a[i]);
end.