#include <bits/stdc++.h>
using namespace std;
struct group {
  int sz;
  vector<int> worst, best;
  group(vector<int>& a)
      : sz(1), worst(a.begin(), a.end()), best(a.begin(), a.end()) {}
  bool operator<(const group& a) const {
    for (int i = 0; i < best.size(); i++)
      if (best[i] >= a.worst[i]) return false;
    return true;
  }
  struct group& operator+=(const group& a) {
    sz += a.sz;
    for (int i = 0; i < best.size(); i++) {
      best[i] = max(best[i], a.best[i]);
      worst[i] = min(worst[i], a.worst[i]);
    }
    return *this;
  }
};
set<group> positions;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  while (n--) {
    vector<int> skills(k, 0);
    for (int i = 0; i < k; i++) scanf("%d", &skills[i]);
    group player = group(skills);
    auto f = positions.lower_bound(player), l = positions.upper_bound(player);
    while (f != l) {
      player += *f;
      f = positions.erase(f);
    }
    positions.insert(f, player);
    printf("%d\n", positions.rbegin()->sz);
  }
  return 0;
}
