Program chik;
var c:array[1..1000,1..1000]of longint;
n,m,i,j,p:longint;
begin
read(n,m);
for i:=1 to n do
beginf
or j:=1 to m do
begin
read(c[i,j]);
end;
end;
for j:=1 to m do
begin
p:=c[3,j];
c[3,j]:=c[5,j];
c[5,j]:=p;
end;
for i:=1 to n do
begin
for j:=1 to m do
begin
write(c[i,j]:3,' ');
end;
writeln;
end;
end.