#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10, mod = 1e9 + 7, M = 10;
set<pair<int, int> > mn[M], mx[M];
int mnval[N][M], mxval[N][M], sz[N], num[N][M], myid[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      cin >> num[i][j];
    }
    v.push_back({num[i][0], i});
  }
  sort(v.begin(), v.end());
  int cur = 0;
  for (pair<int, int> x : v) {
    myid[x.second] = cur++;
  }
  for (int ii = 0; ii < n; ii++) {
    int a[k];
    for (int j = 0; j < k; j++) {
      a[j] = num[ii][j];
    }
    int i = myid[ii];
    int lastwin = -1, firstlose = mod;
    for (int j = 0; j < k; j++) {
      auto it = mn[j].lower_bound(make_pair(a[j], -1));
      if (!mn[j].empty() && it != mn[j].begin()) {
        it--;
        lastwin = max(lastwin, (*it).second);
      }
      it = mx[j].lower_bound(make_pair(a[j], -1));
      if (!mx[j].empty() && it != mx[j].end()) {
        firstlose = min(firstlose, (*it).second);
      }
    }
    if (lastwin < firstlose) {
      for (int j = 0; j < k; j++) {
        mnval[i][j] = mxval[i][j] = a[j];
        mn[j].insert({a[j], i});
        mx[j].insert({a[j], i});
      }
      sz[i] = 1;
    } else {
      vector<int> ids;
      auto it = mn[0].lower_bound(make_pair(mnval[firstlose][0], firstlose));
      int add = 0;
      while (it != mn[0].end() && (*it).second <= lastwin) {
        ids.push_back((*it).second);
        add += sz[(*it).second];
        it++;
      }
      for (int j = 0; j < k; j++) {
        for (int v : ids) {
          mn[j].erase({mnval[v][j], v});
          mx[j].erase({mxval[v][j], v});
        }
        mnval[ids[0]][j] = min(mnval[ids[0]][j], a[j]);
        mxval[ids[0]][j] = max(mxval[ids.back()][j], a[j]);
        mn[j].insert({min(mnval[ids[0]][j], a[j]), ids[0]});
        mx[j].insert({max(mxval[ids.back()][j], a[j]), ids[0]});
      }
      sz[ids[0]] = add + 1;
    }
    int id = (*mn[0].rbegin()).second;
    cout << sz[id] << "\n";
  }
  return 0;
}
