#include <bits/stdc++.h>
using namespace std;
int N, K;
struct P {
  vector<int> m, M;
  int t = 1;
  P() {
    for (int i = 0; i < K; i++) {
      int a;
      scanf("%d", &a);
      m.push_back(a);
      M.push_back(a);
    }
  }
  bool operator<(const P &o) const {
    for (int i = 0; i < K; i++)
      if (M[i] > o.m[i]) return false;
    return true;
  }
  bool operator==(const P &o) const {
    return (*this < o && o < *this) || !(*this < o || o < *this);
  }
};
set<P> S;
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) {
    P a = P();
    auto x = S.lower_bound(a), y = S.upper_bound(a);
    while (x != y) {
      for (int i = 0; i < K; i++) {
        a.m[i] = min(a.m[i], x->m[i]);
        a.M[i] = max(a.M[i], x->M[i]);
      }
      a.t += x->t;
      x = S.erase(x);
    }
    S.insert(a);
    printf("%d\n", S.rbegin()->t);
  }
}
