var
i,n,x,y:longint;
a:array [1..1000] of longint;
begin
randomize;
readln(n);
x:=1;
y:=1;
for i:=1 to n do
begin
a[i]:=random(100);
If a[i] mod 3=0
then x:=x*a[i]
else if a[i] mod 4=0 then y:=y*a[i];
write(a[i],' ');writeln;
end;
writeln(x,' ',y);
end.