uses crt;
var f:text; a,m,d,k:longint;
b:array[1..2]of longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
function ghep(a,b:longint):longint;
var s,s1:string;
begin
str(a,s);
str(b,s1);
val(s+s1,ghep);
end;
begin
clrscr;
assign(f,'input.pas');reset(f);
readln(f,k);
close(f);
assign(f,'output.pas');rewrite(f);
a:=1;
repeat
inc(a);
if nt(a) then
begin
inc(d);
if d=3 then d:=1;
b[d]:=a;
end;
if (d=2)and(nt(ghep(b[1],b[2]))) then
begin d:=0; inc(m); end;
until m=k;
writeln(f,b[1],b[2]);
close(f);
end.