#include <bits/stdc++.h>
using namespace std;
int k;
struct node {
  int mn[12], mx[12];
  bool operator<(const node &b) const {
    int i;
    for (i = 1; i <= k; i++)
      if (mx[i] > b.mn[i]) return false;
    return true;
  }
  int c;
} a[50010];
set<node> s;
set<node>::iterator it1, it2, itm;
int main() {
  int n, i, j;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= k; j++) {
      scanf("%d", &a[i].mn[j]);
      a[i].mx[j] = a[i].mn[j];
    }
    a[i].c = 1;
  }
  for (i = 1; i <= n; i++) {
    it1 = s.lower_bound(a[i]);
    it2 = s.upper_bound(a[i]);
    node t = a[i];
    for (; it1 != it2;) {
      for (j = 1; j <= k; j++) {
        t.mn[j] = min(t.mn[j], it1->mn[j]);
        t.mx[j] = max(t.mx[j], it1->mx[j]);
      }
      t.c += it1->c;
      itm = it1;
      it1++;
      s.erase(itm);
    }
    s.insert(t);
    printf("%d\n", (--s.end())->c);
  }
  return 0;
}
