Var
ar, ar1, ar2: array[1..15]of integer;
i, c1, c2: integer;
begin
c1 := 0;
c2 := 0;
for i := 1 to 15 do
begin
read(ar[i]);
if(ar[i] > 4) then begin c1 := c1 + 1; ar1[c1] := ar[i]; end
else begin c2 := c2 + 1; ar2[c2] := ar[i]; end;
end;
//вывод двух новых массивов.
for i := 1 to c1 do if(ar1[i] <> 0) then write(ar1[i], ' ');
writeln;
for i := 1 to c2 do if(ar2[i] <> 0) then write(ar2[i], ' ');
end.