#include <bits/stdc++.h>
using namespace std;
const int N = 300011;
const int oo = 2e9;
const int LOGN = 18;
int n, k, s[11];
struct group {
  vector<int> mn, mx;
  int sz;
  group() {
    sz = 1;
    mn.resize(k);
    mx.resize(k);
  }
  bool canBeat(const group &b) const {
    for (int i = 0; i < b.mn.size(); ++i) {
      if (mx[i] > b.mn[i]) return true;
    }
    return false;
  }
  void uni(group a) {
    sz += a.sz;
    for (int i = 0; i < a.mn.size(); ++i) {
      mn[i] = min(mn[i], a.mn[i]);
      mx[i] = max(mx[i], a.mx[i]);
    }
  }
  bool operator<(const group &rhs) const {
    return rhs.canBeat(*this) && !canBeat(rhs);
  }
};
int main() {
  scanf("%d%d", &n, &k);
  multiset<group> g;
  for (int i = 0; i < n; ++i) {
    group cur;
    for (int j = 0; j < k; ++j) {
      scanf("%d", &cur.mn[j]);
      cur.mx[j] = cur.mn[j];
    }
    multiset<group>::iterator it = g.upper_bound(cur);
    vector<multiset<group>::iterator> rem;
    while (it != g.begin()) {
      --it;
      if ((*it).canBeat(cur) && cur.canBeat(*it)) {
        rem.push_back(it);
        cur.uni(*it);
      } else {
        break;
      }
    }
    while (rem.size()) {
      g.erase(rem.back());
      rem.pop_back();
    }
    g.insert(cur);
    printf("%d\n", (*--g.end()).sz);
  }
  return 0;
}
