#include <bits/stdc++.h>
using namespace std;
int k;
struct scc {
  scc(int n) : hi(k), lo(k) { size = 1; }
  vector<int> hi, lo;
  int size;
};
bool compMin(scc t1, scc t2) {
  for (int i = 0; i < k; i++) {
    if (t1.hi[i] >= t2.lo[i]) return false;
  }
  return true;
}
scc merge(scc t1, scc t2) {
  t1.size += t2.size;
  for (int i = 0; i < t1.hi.size(); i++) {
    t1.hi[i] = max(t2.hi[i], t1.hi[i]);
    t1.lo[i] = min(t2.lo[i], t1.lo[i]);
  }
  return t1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n >> k;
  set<scc, bool (*)(scc, scc)> sccs(compMin);
  for (int i = 0; i < n; i++) {
    scc temp(k);
    for (int j = 0; j < k; j++) {
      cin >> temp.hi[j];
      temp.lo[j] = temp.hi[j];
    }
    auto beg = sccs.lower_bound(temp);
    auto end = sccs.upper_bound(temp);
    while (beg != end) {
      temp = merge(temp, *beg);
      beg = sccs.erase(beg);
    }
    sccs.insert(temp);
    cout << sccs.rbegin()->size << endl;
  }
  return 0;
}
