from collections import deque import heapq N, M = map(int, input().split()) data = [[]for j in range(M)] for i in range(N): x = list(map(int, input().split())) data.append(x) for j in range(M): data[j].append(x[j]) get_index = [[-1 for i in range(N)] for j in range(M)] for i in range(M): que = [] heapq.heapify(que) X = data[i] MAX = 0 for j in range(N): heapq.heappush(que, (X[j], j)) MAX = max(X[j], MAX) while que[0][0] < MAX: value, index = heapq.heappop(que) get_index[i][index] = j for value, index in que: get_index[i][index] = N D = deque() for i in range(N): maxi = i for j in range(M): maxi = max(maxi, get_index[j][i]) D.append((i, 1)) D.append((maxi, -1)) ans = [0 for i in range(N+1)] while D: x, v = D.popleft() ans[x] += v for i in range(N): ans[i+1] += ans[i] for i in range(N): print(ans[i])