#include<bits/stdc++.h>

using namespace std;


int main() {
  int N, M, R[100000][10];

  stack< int > st[10];
  int in[100000] = {}, sz = 0;

  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cin >> R[i][j];

      while(!st[j].empty() && R[st[j].top()][j] < R[i][j]) {
        if(--in[st[j].top()] == 0) --sz;
        st[j].pop();
      }

      if(st[j].empty() || R[st[j].top()][j] == R[i][j]) {
        if(++in[i] == 1) ++sz;
        st[j].push(i);
      }
    }
    cout << sz << endl;
  }
}