const
	MaxN = 2012;

var
        inFile, outFile : text;
	n, m, i, j: longint;
	s : array[0..MaxN, 0..MaxN] of char;
	ind, sol : array[0..MaxN] of longint;

function less(a, b : longint) : boolean;
var
	i : longint;
	q : boolean;
begin
        q := false;
	for i := 1 to n do
	begin
		if (s[a][i] > s[b][i]) then q := true;
		if (s[a][i] < s[b][i]) then q := false;
		if (s[a][i] <> s[b][i]) then break;
	end;

	less := q;
end;

procedure QS(l, r : longint);
var
        i , j, mid, x, tmp2 : longint;
        tmp : char;
begin
	i := l; j := r;
        mid := (l + r) div 2;
        for x := 1 to n do s[m + 1][x] := s[mid][x];
        repeat
		while (less(i, m + 1)) do i := i + 1;
		while (less(m + 1, j)) do j := j - 1;
		if (i <= j) then
		begin
			for x := 1 to n do
			begin
				tmp := s[i][x]; s[i][x] := s[j][x]; s[j][x] := tmp;
			end;
			tmp2 := ind[i]; ind[i] := ind[j]; ind[j] := tmp2;
                        i := i + 1; j := j - 1;
		end;
	until (i > j);

	if (l < j) then QS(l, j);
	if (i < r) then QS(i, r);
end;

BEGIN

	assign(inFile, 'kljuc.in');
	assign(outFile, 'kljuc.out');
	reset(inFile); rewrite(outFile);

	readln(inFile, n, m);
	for i := 1 to n do
	begin
		for j := 1 to m do
			read(inFile, s[j][i]);
		readln(inFile);
	end;

	for i := 1 to m do
		ind[i] := i;
	QS(1, m);
	for i := 1 to m do
		sol[ ind[i] ] := i;

	for i := 1 to m - 1 do
		write(outFile, sol[i], ' ');
	writeln(outFile, sol[m]);

	close(inFile);
	close(outFile);

END.
