import sys

input = sys.stdin.readline

N, M = map(int, input().split())
max_param = [0] * M
winners = [[] for _ in range(M)]
people = [0] * N
ans = 0
for i in range(N):
    R = map(int, input().split())
    for j, r in enumerate(R):
        if max_param[j] < r:
            for x in winners[j]:
                people[x] -= 1
                if not people[x]:
                    ans -= 1
            winners[j].clear()

            max_param[j] = r

        if max_param[j] == r:
            if not people[i]:
                ans += 1
            people[i] += 1

            winners[j].append(i)
    print(ans)