import sys input = sys.stdin.readline from bisect import bisect N,M=map(int,input().split()) MAX=[i for i in range(N)] R=[list(map(int,input().split())) for i in range(N)] for i in range(M): X=[] for j in range(N): X.append(R[j][i]) #print(X) Y=[] for j in range(N): if Y==[] or X[j]>Y[-1][0]: Y.append((X[j],j)) #print(Y) for j in range(N): k=bisect(Y,(X[j],1<<30)) if ki: ANS[i]+=1 ANS[MAX[i]]-=1 for i in range(1,N+1): ANS[i]+=ANS[i-1] for ans in ANS[:-1]: print(ans)