#include <bits/stdc++.h>
using namespace std;
struct Squad {
  int n;
  vector<int> mins;
  vector<int> maxs;
  bool operator<(Squad s) const {
    for (int i = 0; i < maxs.size(); ++i) {
      if (maxs[i] > s.mins[i]) {
        return false;
      }
    }
    return true;
  }
};
Squad join(Squad a, Squad b) {
  Squad ans;
  ans.n = a.n + b.n;
  int l = a.mins.size();
  ans.mins.resize(l);
  ans.maxs.resize(l);
  for (int i = 0; i < l; ++i) {
    ans.mins[i] = min(a.mins[i], b.mins[i]);
    ans.maxs[i] = max(a.maxs[i], b.maxs[i]);
  }
  return ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  set<Squad> competitors;
  for (int i = 0; i < n; ++i) {
    Squad newcomer;
    newcomer.n = 1;
    newcomer.mins.resize(k);
    newcomer.maxs.resize(k);
    for (int j = 0; j < k; ++j) {
      int skill;
      cin >> skill;
      newcomer.mins[j] = skill;
      newcomer.maxs[j] = skill;
    }
    while ((competitors.lower_bound(newcomer) != competitors.end()) &&
           !(newcomer < *competitors.lower_bound(newcomer))) {
      auto it = competitors.lower_bound(newcomer);
      newcomer = join(newcomer, *it);
      competitors.erase(it);
    }
    competitors.insert(newcomer);
    cout << competitors.rbegin()->n << endl;
  }
  return 0;
}
