var a, b, c, d, k, i, j, n1, n2 :integer;
s: array [1..100,1..100] of integer;
procedure swap(a, b :integer; var c, d :integer);
var e :integer;
begin
c:=b;
d:=a;
end;
begin
read (n1, n2);
for i:=1 to n1 do
for j:=1 to n2 do
read (s[i,j]);
for j:=1 to n2 do
swap (s[1,j],s[3,j],s[1,j],s[3,j]);
for i:=1 to n1 do
begin
writeln;
for j:=1 to n2 do
write (s[i,j],' ');
end
end.