#include <bits/stdc++.h>
using namespace std;
int n, k;
struct node {
  int minn[15];
  int maxn[15];
  int sz;
  friend bool operator<(node a, node b) {
    for (int i = 0; i < k; i++) {
      if (a.maxn[i] > b.minn[i]) return false;
    }
    return true;
  }
};
set<node> s;
int main() {
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 0; i < n; i++) {
      node cur;
      cur.sz = 1;
      for (int j = 0; j < k; j++) {
        scanf("%d", &cur.minn[j]);
        cur.maxn[j] = cur.minn[j];
      }
      set<node>::iterator x = s.lower_bound(cur);
      set<node>::iterator y = s.upper_bound(cur);
      while (x != y) {
        cur.sz += x->sz;
        for (int j = 0; j < k; j++) {
          cur.minn[j] = min(cur.minn[j], x->minn[j]);
          cur.maxn[j] = max(cur.maxn[j], x->maxn[j]);
        }
        s.erase(x++);
      }
      s.insert(cur);
      printf("%d\n", s.rbegin()->sz);
    }
  }
}
