#include <bits/stdc++.h>
using namespace std;
int n, k;
struct Point {
  int up[15], down[15], sz;
  bool operator<(const Point &oth) const {
    for (int i = 1; i <= k; i++)
      if (down[i] < oth.up[i]) return 0;
    return 1;
  }
} tmp;
set<Point> s;
int main() {
  int t;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++)
      scanf("%d", &t), tmp.up[j] = tmp.down[j] = t, tmp.sz = 1;
    auto x = s.lower_bound(tmp), y = s.upper_bound(tmp);
    while (x != y) {
      tmp.sz += x->sz;
      for (int j = 1; j <= k; j++)
        tmp.up[j] = max(tmp.up[j], x->up[j]),
        tmp.down[j] = min(tmp.down[j], x->down[j]);
      s.erase(x++);
    }
    s.insert(tmp);
    cout << s.begin()->sz << endl;
  }
  return 0;
}
