#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
int n, k;
struct Node {
  int mx[20], mn[20], sz;
  void init(int _, int __) {
    for (int i = 1; i <= k; i++) mx[i] = mn[i] = _;
    sz = __;
  }
  bool operator<(const Node &_) const {
    for (int i = 1; i <= k; i++) {
      if (mx[i] > _.mn[i]) return 0;
    }
    return 1;
  }
  void unit(const Node &_) {
    sz += _.sz;
    for (int i = 1; i <= k; i++)
      mx[i] = max(mx[i], _.mx[i]), mn[i] = min(mn[i], _.mn[i]);
  }
};
set<Node> S;
vector<set<Node>::iterator> del;
int main() {
  scanf("%d%d", &n, &k);
  Node tmp;
  for (int i = 1; i <= n; i++) {
    tmp.sz = 1;
    for (int j = 1; j <= k; j++) scanf("%d", tmp.mx + j), tmp.mn[j] = tmp.mx[j];
    set<Node>::iterator l, r, it;
    l = S.lower_bound(tmp);
    r = S.upper_bound(tmp);
    for (it = l; it != r; it++) {
      del.push_back(it);
      tmp.unit(*it);
    }
    for (int j = 0; j < del.size(); j++) S.erase(del[j]);
    del.clear();
    S.insert(tmp);
    it = S.end();
    it--;
    printf("%d\n", it->sz);
  }
  return 0;
}
