import sys from collections import defaultdict input=sys.stdin.readline write=sys.stdout.write N,M=map(int,input().split()) Set=[set()]*M Max=[0]*M Z=[0]*N for i in range(N): R=list(map(int,input().split())) for k in range(M): if R[k]==Max[k]: Set[k].add(i) elif R[k]>Max[k]: Max[k]=R[k] Set[k]={i} X=set() for k in range(M): X|=Set[k] Z[i]=len(X) write("\n".join(map(str,Z)))