#include <bits/stdc++.h>
using namespace std;
int n, k;
struct node {
  int mn[11], mx[11], sz;
  bool operator<(const node &p) const {
    for (int i = 1; i <= k; i++)
      if (mx[i] > p.mn[i]) return 0;
    return 1;
  }
} now;
set<node> S;
set<node>::iterator it;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    now.sz = 1;
    for (int j = 1; j <= k; j++) scanf("%d", &now.mn[j]), now.mx[j] = now.mn[j];
    for (; (it = S.find(now)) != S.end(); S.erase(it)) {
      now.sz += (*it).sz;
      for (int j = 1; j <= k; j++)
        now.mn[j] = min(now.mn[j], (*it).mn[j]),
        now.mx[j] = max(now.mx[j], (*it).mx[j]);
    }
    S.insert(now);
    printf("%d\n", (*S.rbegin()).sz);
  }
}
