#include <bits/stdc++.h>
using namespace std;
int N, K;
struct Level {
  int lo[10 + 5], hi[10 + 5], sz;
  bool operator<(const Level &l) const {
    for (int i = 0; i < K; i++) {
      if (hi[i] >= l.lo[i]) return false;
    }
    return true;
  }
};
Level s[50000 + 5];
set<Level> ps;
void merge(Level &tar, const Level &src) {
  for (int i = 0; i < K; i++) {
    tar.lo[i] = min(tar.lo[i], src.lo[i]);
    tar.hi[i] = max(tar.hi[i], src.hi[i]);
  }
  tar.sz += src.sz;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    s[i].sz = 1;
    for (int j = 0; j < K; j++) {
      cin >> s[i].lo[j];
      s[i].hi[j] = s[i].lo[j];
    }
    auto it1 = ps.lower_bound(s[i]), it2 = ps.upper_bound(s[i]);
    while (!ps.empty() && it1 != it2) {
      merge(s[i], *it1);
      ps.erase(it1);
      it1 = ps.lower_bound(s[i]);
      it2 = ps.upper_bound(s[i]);
    }
    ps.insert(s[i]);
    cout << (--ps.end())->sz << '\n';
  }
}
