#include <bits/stdc++.h>
using namespace std;
int n, k;
struct node {
  int sz;
  vector<int> mn, mx;
  node() {
    sz = 1;
    for (int i = 0, x; i < k; ++i)
      scanf("%d", &x), mn.push_back(x), mx.push_back(x);
  }
  bool operator<(const node& a) const {
    for (int i = 0; i < k; ++i)
      if (mx[i] > a.mn[i]) return 0;
    return 1;
  }
  void merge(const node& a) {
    for (int i = 0; i < k; ++i)
      mn[i] = min(mn[i], a.mn[i]), mx[i] = max(mx[i], a.mx[i]);
    sz += a.sz;
  }
};
set<node> S;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    node a = node();
    auto L = S.lower_bound(a), R = S.upper_bound(a);
    while (L != R) a.merge(*L), L = S.erase(L);
    S.insert(a);
    printf("%d\n", (S.rbegin())->sz);
  }
}
