#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n, k;
struct node {
  int mx[10], mi[10], sz;
  bool operator<(const node &b) const {
    for (int i = 0; i < k; i++) {
      if (mx[i] > b.mi[i]) return false;
    }
    return true;
  }
};
set<node> S;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    node a;
    for (int j = 0; j < k; j++) {
      scanf("%d", &a.mx[j]);
      a.mi[j] = a.mx[j];
      a.sz = 1;
    }
    set<node>::iterator x = S.lower_bound(a);
    set<node>::iterator y = S.upper_bound(a);
    while (x != y) {
      a.sz += x->sz;
      for (int j = 0; j < k; j++) {
        a.mi[j] = min(a.mi[j], x->mi[j]);
        a.mx[j] = max(a.mx[j], x->mx[j]);
      }
      S.erase(x++);
    }
    S.insert(a);
    cout << S.rbegin()->sz << endl;
  }
}
