#include <bits/stdc++.h>
using namespace std;
const int K = 13;
int n, k;
struct node {
  int mn[K], mx[K], sz;
  friend bool operator<(node A, node B) {
    for (register int i = (1); i <= (k); ++i)
      if (A.mx[i] > B.mn[i]) return 0;
    return 1;
  }
} t;
set<node> g;
set<node>::iterator it;
void Inc() {
  cout << "!!" << '\n';
  it = g.begin();
  for (; it != g.end(); it++) {
    cout << it->sz << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (register int i = (1); i <= (n); ++i) {
    for (register int j = (1); j <= (k); ++j) cin >> t.mn[j], t.mx[j] = t.mn[j];
    t.sz = 1;
    while (g.size() && g.find(t) != g.end()) {
      it = g.find(t);
      t.sz += it->sz;
      for (register int j = (1); j <= (k); ++j)
        t.mn[j] = min(t.mn[j], it->mn[j]), t.mx[j] = max(t.mx[j], it->mx[j]);
      g.erase(it);
    }
    g.insert(t);
    it = g.end();
    it--;
    cout << it->sz << '\n';
  }
  return 0;
}
