import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
Ma = [0]*M
cnt = [0]*N
ans = 0
idx = [defaultdict(list) for _ in range(M)]

for i in range(N):
    R = list(map(int, input().split()))
    
    for j in range(M):
        if R[j]==Ma[j]:
            if cnt[i]==0:
                ans += 1
            
            cnt[i] += 1
            idx[j][Ma[j]].append(i)
        elif R[j]>Ma[j]:
            for k in idx[j][Ma[j]]:
                cnt[k] -= 1
                
                if cnt[k]==0:
                    ans -= 1
            
            if cnt[i]==0:
                ans += 1
            
            cnt[i] += 1
            Ma[j] = R[j]
            idx[j][Ma[j]].append(i)

    print(ans)