#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff, N = 5e4 + 500;
int gti(void) {
  char c = getchar();
  int ret = 0, st = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-') st = -1;
  for (; isdigit(c); c = getchar()) ret = ret * 10 + c - '0';
  return ret * st;
}
struct P {
  int sum, mn[15], mx[15];
  bool operator<(const P &b) const { return mn[1] < b.mn[1]; }
};
set<P> s;
set<P>::iterator e[N];
void insert(P now, int k) {
  set<P>::iterator l, r;
  l = s.lower_bound(now);
  r = s.lower_bound(now);
  int tot = 0;
  if (l != s.begin())
    for (l--; true; l--) {
      bool tag = false;
      for (int i = 1; i <= k; i++)
        if (l->mx[i] > now.mn[i]) {
          e[++tot] = l;
          tag = true;
          break;
        }
      if (!tag || l == s.begin()) break;
    }
  for (; true; r++) {
    bool tag = false;
    for (int i = 1; i <= k; i++)
      if (r->mn[i] < now.mx[i]) {
        e[++tot] = r;
        tag = true;
        break;
      }
    if (!tag || r == s.end()) break;
  }
  for (int i = 1; i <= tot; i++) {
    for (int j = 1; j <= k; j++) {
      now.mn[j] = min(now.mn[j], e[i]->mn[j]);
      now.mx[j] = max(now.mx[j], e[i]->mx[j]);
    }
    now.sum += e[i]->sum;
    s.erase(e[i]);
  }
  s.insert(now);
}
int main(void) {
  int n = gti(), k = gti();
  P lst;
  for (int i = 1; i <= k; i++) lst.mx[i] = lst.mn[i] = inf;
  s.insert(lst);
  for (int i = 1; i <= n; i++) {
    P now;
    for (int j = 1; j <= k; j++) now.mx[j] = now.mn[j] = gti();
    now.sum = 1;
    insert(now, k);
    set<P>::iterator x = s.end();
    x--, x--;
    printf("%d\n", x->sum);
  }
  return 0;
}
