#include <bits/stdc++.h>
using namespace std;
int n, k;
struct sport {
  int mn[12], mx[12], ans;
  sport(int x = 1) {
    memset(mn, 0, sizeof(mn));
    memset(mx, 0, sizeof(mx));
    ans = x;
  }
  bool operator<(const sport &x) const {
    for (int i = 0; i < k; ++i)
      if (mx[i] > x.mn[i]) return false;
    return true;
  }
};
set<sport> s;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    sport sp;
    for (int j = 0, t; j < k; ++j) {
      scanf("%d", &t);
      sp.mn[j] = sp.mx[j] = t;
    }
    set<sport>::iterator p = s.lower_bound(sp), q = s.upper_bound(sp);
    while (p != q) {
      for (int j = 0; j < k; ++j) {
        sp.mn[j] = min(sp.mn[j], p->mn[j]);
        sp.mx[j] = max(sp.mx[j], p->mx[j]);
      }
      sp.ans += p->ans;
      s.erase(p++);
    }
    s.insert(sp);
    printf("%d\n", s.rbegin()->ans);
  }
  return 0;
}
