Const
e=10000;
var
a:array[1..e,1..e] of real;
i,j,n,m:integer;
k:real;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
for i:=1 to n do
for j:=i+1 to m do
begin
k:=a[i,j];
a[i,j]:=a[j,i];
a[j,i]:=k;
end;
for i:=1 to m do
begin
for j:=1 to n do
write(a[i,j],' ');
writeln;
end;
end.