var
a,i,s,k,m,j,y:integer;
b:array[1..1000] of longint;
begin
for i:=1 to 9 do
for j:=3 to 3 do
for m:=6 to 6 do
for k:=1 to 9 do
begin
s:=i*1000+300+60+k;
if (s mod 2=0) and (s mod 3=0) then begin inc(y); b[y]:=s;end;
end;
write(b[y],' ',b[1]);
end.