#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N, vector<int>(M));
  vector<int> mx(M, -1);
  vector<map<int,int>> mp(M);
  rep(i,N){
    rep(j,M){
      cin >> v[i][j];
      mx[j] = max(mx[j], v[i][j]);
      mp[j][mx[j]] = i;
    }
  }

  vector<int> ret(N+1,0);
  rep(i,N){
    int x = -1;
    rep(j,M){
      x = max(x, mp[j][v[i][j]]);
    }
    if(i <= x){
      ret[i]++;
      ret[x+1]--;
    }
  }

  int base = 0;
  rep(i,N){
    base += ret[i];
    cout << base << endl;
  }
  
  return 0;
}