import sys input=sys.stdin.readline write=sys.stdout.write N,M=map(int,input().split()) Count =[0]*(M+1) Chance=[0]*N Max =[-1]*M Person=[[] for _ in range(M)] X=[0]*N for k in range(N): R=list(map(int,input().split())) Count[0]+=1 for j in range(M): if R[j]>=Max[j]: Count[Chance[k]]-=1 Chance[k]+=1 Count[Chance[k]]+=1 if R[j]==Max[j]: Person[j].append(k) elif R[j]>Max[j]: for t in Person[j]: Count[Chance[t]]-=1 Chance[t]-=1 Count[Chance[t]]+=1 Max[j]=R[j] Person[j]=[k] X[k]=k+1-Count[0] write("\n".join(map(str,X)))