type
	item = array[0..15] of longint;

var
	i, j, n, k : longint;
	a : array[0..100010] of item;

procedure sort(l, r : longint);

	function cmp(a, b : item) : boolean;

	var
		i : longint;

	begin
		for i := 1 to k do
			if a[i] > b[i] then begin
				cmp := true;
				exit;
			end else
			if a[i] < b[i] then begin
				cmp := false;
				exit;
			end;
		cmp := false;
	end;

var
	i, j : longint;
	x, y : item;

begin
	i := l;
	j := r;
	x := a[l + random(r - l + 1)];
	repeat
		while cmp(a[i], x) do inc(i);
		while cmp(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 l < j then sort(l, j);
	if i < r then sort(i, r);
end;
	
begin
	randomize();  
	read(n, k);
	for i := 1 to n do begin
		for j := 1 to k do
			read(a[i][j]);
		a[i][0] := i;
	end;
	sort(1, n);
	for i := 1 to n do
		write(a[i][0], ' ');
end.
