#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 5;
int n, k;
struct node {
  int lo[10], hi[10];
  int size;
  node() { size = 1; }
  void init() {
    for (int i = 0; i < k; i++) {
      int x;
      cin >> x;
      lo[i] = hi[i] = x;
    }
  }
  int score(const node& o) const {
    int res = 0;
    for (int i = 0; i < k; i++) {
      if (o.hi[i] > lo[i]) {
        res |= 1;
      }
      if (hi[i] > o.lo[i]) {
        res |= 2;
      }
    }
    return res;
  }
  void merge(const node& o) {
    for (int i = 0; i < k; i++) {
      lo[i] = min(lo[i], o.lo[i]);
      hi[i] = max(hi[i], o.hi[i]);
    }
    size += o.size;
  }
  bool operator<(const node& o) const { return score(o) == 1; }
};
set<node> s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    node cur;
    cur.init();
    auto it1 = s.lower_bound(cur);
    auto it2 = it1;
    while (it2 != s.end() && cur.score(*it2) == 3) {
      cur.merge(*it2);
      ++it2;
    }
    s.erase(it1, it2);
    s.insert(cur);
    cout << s.rbegin()->size << "\n";
  }
  return 0;
}
