var i,j,k,l,a,b,c,max:longint;
x:array[1..10000,1..200]of longint;
procedure qsort(l,r:longint);
var i,j,mid,y,t,l1:longint;
begin
i:=l;j:=r;mid:=(l+r) div 2;
repeat
repeat
t:=0;
for l1:=1 to k do begin
if x[i,l1]<x[mid,l1] then t:=1
else if x[i,l1]>x[mid,l1] then t:=2;
if t<>0 then break;
end;
if t=1 then inc(i);
until t<>1;
repeat
t:=0;
for l1:=1 to k do begin
if x[mid,l1]<x[j,l1] then t:=1
else if x[mid,l1]>x[j,l1] then t:=2;
if t<>0 then break;
end;
if t=1 then dec(j);
until t<>1;
if i<=j then begin
for l1:=1 to k do begin
y:=x[i,l1];x[i,l1]:=x[j,l1];x[j,l1]:=y;
end;
inc(i);dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
while not eof do begin
readln(a,k);
for i:=1 to a do
for j:=1 to k do read(x[i,j]);
qsort(1,a);
for i:=1 to a do begin
for j:=1 to k do write(x[i,j],' ');
writeln;
end;
end;
end.
20分。。果断求助