#include <bits/stdc++.h>
using namespace std;
int n, k;
struct spman {
  int mstr[10], Mstr[10], sz;
  spman() {
    sz = 1;
    int tmp;
    for (int i = 0; i < k; i++) {
      scanf("%d", &tmp);
      mstr[i] = Mstr[i] = tmp;
    }
  }
};
struct cmp {
  bool operator()(const spman &a, const spman &b) {
    for (int i = 0; i < k; i++)
      if (a.Mstr[i] > b.mstr[i]) return false;
    return true;
  }
};
void mergedesu(spman &a, const spman &b) {
  for (int i = 0; i < k; i++) {
    a.Mstr[i] = max(a.Mstr[i], b.Mstr[i]);
    a.mstr[i] = min(a.mstr[i], b.mstr[i]);
  }
  a.sz += b.sz;
}
set<spman, cmp> all;
int main() {
  scanf("%d%d", &n, &k);
  set<spman, cmp>::iterator lp, hp;
  for (int i = 0; i < n; i++) {
    spman tman = spman();
    lp = all.lower_bound(tman);
    hp = all.upper_bound(tman);
    while (lp != hp) {
      mergedesu(tman, *lp);
      all.erase(lp++);
    }
    all.insert(tman);
    printf("%d\n", all.rbegin()->sz);
  }
  return 0;
}
