#include <bits/stdc++.h>
int n, k, s[50010][10];
struct item {
  int id, ty;
  bool operator<(const item& it) const {
    if (s[id][ty] != s[it.id][ty]) return s[id][ty] < s[it.id][ty];
    return id < it.id;
  }
};
std::set<item> st[10], S;
int fa[50010], siz[50010];
int find(int i) { return fa[i] == i ? i : fa[i] = find(fa[i]); }
void merge(int i, int j) {
  fa[i = find(i)] = j = find(j);
  siz[j] += siz[i];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) fa[i] = i, siz[i] = 1;
  for (int i = 0; i < n; i++) {
    int x = -1, y = -1;
    for (int j = 0; j < k; j++) {
      scanf("%d", s[i] + j);
      std::set<item>::iterator it = st[j].insert((item){i, j}).first;
      if (it != st[j].begin()) {
        it--;
        if (x < 0 || *s[it->id] > *s[x]) x = it->id;
        it++;
      }
      it++;
      if (it != st[j].end() && (y < 0 || *s[y] > *s[it->id])) y = it->id;
    }
    if (x > -1 && y > -1) {
      std::set<item>::iterator ix = S.find((item){find(x), 0}),
                               iy = S.find((item){find(y), 0}), it;
      for (ix++; iy != ix; it = iy++, S.erase(it)) merge(iy->id, i);
    }
    S.insert((item){i, 0});
    printf("%d\n", siz[find(S.rbegin()->id)]);
  }
}
