#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> min;
  vector<int> max;
  size_t size;
  node(size_t k) : min(k), max(k), size(1) {}
  bool operator<(const node& rhs) const {
    for (int i = 0; i < max.size(); i++)
      if (rhs.min[i] < max[i]) return false;
    return true;
  }
};
set<node> order;
int m, k, x;
int main() {
  ios::sync_with_stdio(false);
  cin >> m >> k;
  while (m--) {
    node tmp(k);
    for (int i = 0; i < k; i++) {
      cin >> x;
      tmp.max[i] = x;
      tmp.min[i] = x;
    }
    auto x = order.lower_bound(tmp);
    auto y = order.upper_bound(tmp);
    while (x != y) {
      tmp.size += x->size;
      for (int i = 0; i < k; i++) {
        tmp.max[i] = max(tmp.max[i], x->max[i]);
        tmp.min[i] = min(tmp.min[i], x->min[i]);
      }
      order.erase(x++);
    }
    order.insert(tmp);
    cout << order.rbegin()->size << endl;
  }
  return 0;
}
