#include <bits/stdc++.h>
using namespace std;
void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
}
const int MAXN = 5e4 + 4;
int n, k;
struct SCC {
  int minval[11], maxval[11];
  int sz;
  bool operator<(const SCC& other) {
    for (int i = 1; i <= k; i++) {
      if (maxval[i] > other.minval[i]) {
        return 0;
      }
    }
    return 1;
  }
};
SCC scc[MAXN * 2];
struct cptr {
  bool operator()(const int& x, const int& y) const {
    return scc[x].minval[1] < scc[y].minval[1];
  }
};
set<int, cptr> comps;
set<pair<int, int> > lft[11], rgt[11];
int pool;
set<int, cptr> L, R;
void insert(SCC& a) {
  if (comps.empty() || a < scc[*comps.begin()] || scc[*prev(comps.end())] < a) {
    scc[++pool] = a;
    for (int i = 1; i <= k; i++) {
      lft[i].insert({a.maxval[i], pool});
      rgt[i].insert({a.maxval[i], pool});
    }
    comps.insert(pool);
  } else {
    for (int i = 1; i <= k; i++) {
      auto itl = lft[i].lower_bound({a.maxval[i], -1});
      auto itr = rgt[i].lower_bound({a.maxval[i], -1});
      if (itl != lft[i].begin()) {
        itl--;
        L.insert((*itl).second);
      }
      if (itr != rgt[i].end()) {
        R.insert((*itr).second);
      }
    }
    set<int, cptr>::iterator itl = comps.lower_bound(*R.begin());
    set<int, cptr>::iterator itr = comps.lower_bound(*prev(L.end()));
    L.clear();
    R.clear();
    itr++;
    SCC s = a;
    while (itl != itr) {
      int x = *itl;
      for (int i = 1; i <= k; i++) {
        s.maxval[i] = max(s.maxval[i], scc[x].maxval[i]);
        s.minval[i] = min(s.minval[i], scc[x].minval[i]);
        lft[i].erase({scc[x].minval[i], x});
        rgt[i].erase({scc[x].maxval[i], x});
      }
      itl++;
      s.sz += scc[x].sz;
      comps.erase(comps.find(x));
    }
    scc[++pool] = s;
    for (int i = 1; i <= k; i++) {
      lft[i].insert({s.minval[i], pool});
      rgt[i].insert({s.maxval[i], pool});
    }
    comps.insert(pool);
  }
}
int main(int argc, char* argv[]) {
  io();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    SCC a;
    for (int j = 1; j <= k; j++) {
      cin >> a.maxval[j];
      a.minval[j] = a.maxval[j];
    }
    a.sz = 1;
    insert(a);
    cout << scc[*prev(comps.end())].sz << '\n';
  }
  return 0;
}
