def main(): import sys input = sys.stdin.buffer.readline N, M = map(int, input().split()) ma = [0] * M n_list = [[] for _ in range(M)] R = [[0] * M for _ in range(N)] for i in range(N): A = list(map(int, input().split())) for j in range(M): if A[j] > ma[j]: ma[j] = A[j] for k in n_list[j]: R[k][j] = i n_list[j] = [i] elif A[j] == ma[j]: n_list[j].append(i) else: R[i][j] = i for j in range(M): for k in n_list[j]: R[k][j] = N ans = [0] * (N+1) for i in range(N): r = max(R[i]) ans[i] += 1 ans[r] += -1 for i in range(1, N+1): ans[i] += ans[i-1] print('\n'.join(map(str, ans[:N]))) if __name__ == '__main__': main()