Var b:integer;
a: array [0..9] of integer;
begin
randomize;
for b:=0 to 9 do begin
read(a[b]);
end;
for b:=4 downto 0 do begin
write(a[b],' ');
end;
writeln('');
for b:=6 to 9 do begin
write(a[b],' ');
end;
writeln('');
for b:=0 to 9 do begin
if ((b=0)or (b=8)) then write(a[b],' ');
end;
writeln('');
end.