#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
}
enum compare_mode { CMP_SET, CMP_LOW, CMP_HIGH };
struct comp {
  vector<int> low, high;
  int size;
  compare_mode mode = CMP_SET;
  bool operator<(const comp &b) const {
    switch (max(mode, b.mode)) {
      case CMP_SET:
        return low[0] < b.low[0];
      case CMP_LOW:
        for (int i = 0; i < ((long long)(low).size()); i++)
          if (low[i] >= b.low[i]) return false;
        return true;
      case CMP_HIGH:
        for (int i = 0; i < ((long long)(high).size()); i++)
          if (high[i] >= b.high[i]) return false;
        return true;
    }
    return false;
  }
};
int main(int argc, const char **argv) {
  redirect(argc, argv);
  int N, K;
  cin >> N >> K;
  set<comp> comps;
  for (int i = 0; i < N; i++) {
    vector<int> cur(K);
    for (int j = 0; j < K; j++) cin >> cur[j];
    comp test;
    test.low = test.high = cur;
    test.mode = CMP_LOW;
    auto hi = comps.upper_bound(test);
    test.mode = CMP_HIGH;
    auto lo = comps.lower_bound(test);
    comp n;
    n.low = n.high = cur;
    n.size = 1;
    if (lo != hi && (hi == comps.end() || lo != next(hi))) {
      auto hi1 = prev(hi);
      for (int k = 0; k < K; k++) {
        n.low[k] = min(n.low[k], lo->low[k]);
        n.high[k] = max(n.high[k], hi1->high[k]);
      }
      for (auto i = lo; i != hi; ++i) n.size += i->size;
      comps.erase(lo, hi);
    }
    comps.insert(n);
    cout << comps.rbegin()->size << '\n';
  }
  return 0;
}
