#include <bits/stdc++.h>
using namespace std;
int n, k;
struct node {
  int les[10], big[10], sz;
  bool operator<(const node& x) const {
    for (int i = 0; i < k; i++)
      if (big[i] > x.les[i]) return false;
    return true;
  }
};
set<node> s;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    node a;
    a.sz = 1;
    for (int i = 0; i < k; i++) {
      scanf("%d", &a.les[i]);
      a.big[i] = a.les[i];
    }
    auto x = s.lower_bound(a);
    auto y = s.upper_bound(a);
    while (x != y) {
      a.sz += x->sz;
      for (int i = 0; i < k; i++) {
        a.les[i] = min(a.les[i], x->les[i]);
        a.big[i] = max(a.big[i], x->big[i]);
      }
      s.erase(x++);
    }
    s.insert(a);
    printf("%d\n", s.rbegin()->sz);
  }
}
