#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50005, MAXK = 10;
int N, K;
struct Component {
  int size, minS[MAXK], maxS[MAXK];
  bool operator<(const Component &B) const {
    for (int i = 0; i < K; ++i)
      if (maxS[i] > B.minS[i]) return false;
    return true;
  }
} c[MAXN];
set<Component> S;
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < K; ++j)
      scanf("%d", &c[i].minS[j]), c[i].maxS[j] = c[i].minS[j], c[i].size = 1;
    set<Component>::iterator lb = S.lower_bound(c[i]);
    set<Component>::iterator ub = S.upper_bound(c[i]);
    if (lb != ub) {
      for (set<Component>::iterator iter = lb; iter != ub; ++iter) {
        for (int j = 0; j < K; ++j)
          c[i].minS[j] = min(c[i].minS[j], iter->minS[j]),
          c[i].maxS[j] = max(c[i].maxS[j], iter->maxS[j]);
        c[i].size += iter->size;
      }
      S.erase(lb, ub);
    }
    S.insert(c[i]);
    printf("%d\n", S.rbegin()->size);
  }
  return 0;
}
