uses
  SysUtils;
type TItem=array of longint;
var
i,n,k,j:longint;
A:array [1..100000] of TItem;

function qsb(var a,b:TItem):boolean;
var
i:longint;
begin
qsb:=true;
for i:=1 to k do
 begin
  if a[i]<b[i] then exit;
  if A[i]>b[i] then begin qsb:=false; exit; end;
 end;
qsb:=false; 
end;

procedure sort(l,r:longint);
var
i,j:longint;
x,y:TItem;
begin
setlength(x,k+1);
setlength(y,k+1);
i:=l; j:=r; x:=A[l+random(r-l+1)];
repeat
while qsb(A[i],x) do inc(i);
while qsb(x,A[j]) do dec(j);
if i<=j then
 begin
  y:=A[i]; A[i]:=A[j]; A[j]:=y;
  inc(i); dec(j);
 end;
until i>j;
if I<r then sort(i,r);
if l<j then sort(l,j);
end;

begin
randomize();
readln(N,K);
for i:=1 to n do
 begin
  setlength(A[i],k+1);
 A[i,0]:=i;
  for j:=1 to k do
   read(A[i,j]);
 end;
sort(1,n);
for i:=n downto 1 do write(A[i][0],' ');
end.