#include <bits/stdc++.h>
using namespace std;
int k;
struct node {
  int mi[12], mx[12], sz;
  bool operator<(const node &a) const {
    for (int i = 0; i < k; i++)
      if (mx[i] > a.mi[i]) return 0;
    return 1;
  }
} now;
set<node> ss;
int main() {
  int n;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      scanf("%d", &now.mi[j]);
      now.mx[j] = now.mi[j];
      now.sz = 1;
    }
    auto l = ss.lower_bound(now), r = ss.upper_bound(now);
    while (l != r) {
      now.sz += l->sz;
      for (int j = 0; j < k; j++)
        now.mi[j] = min(now.mi[j], l->mi[j]),
        now.mx[j] = max(now.mx[j], l->mx[j]);
      ss.erase(l++);
    }
    ss.insert(now);
    printf("%d\n", ss.rbegin()->sz);
  }
}
