const
  max = 1000;
var
  i, j, x, y, n, k : integer;
  ans : array[1..max] of integer;
  a : array[1..max, 1..max] of integer;
begin
  reset(input, 'satellite.in');
  rewrite(output, 'satellite.out');
  read(n, k);
  for i := 1 to k do begin
    for j := 1 to n do begin
      read(a[i, j]);
    end;
    ans[i] := 0;
  end;
  for i := 1 to k do begin
    for j := 1 to k do begin
      if (i = j) then continue;
      for x := 1 to n do begin
        for y := 1 to n do begin
          if (a[i, x] > a[j, y]) then begin
            ans[i] := ans[i] + 1;
          end;
        end;
      end;
    end;
  end;
  for i := 1 to k do begin
    write(ans[i], ' ');
  end;
end.