#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50005;
int n, k;
struct node {
  int p_max[11], p_min[11], num;
  friend bool operator<(const node &a, const node &b) {
    for (int i = 1; i <= k; i++)
      if (a.p_max[i] > b.p_min[i]) return 0;
    return 1;
  }
  friend bool operator==(const node &a, const node &b) {
    return !(a < b) && !(b < a);
  }
  friend node operator+(const node &a, const node &b) {
    node c;
    for (int i = 1; i <= k; i++)
      c.p_max[i] = max(a.p_max[i], b.p_max[i]),
      c.p_min[i] = min(a.p_min[i], b.p_min[i]);
    c.num = a.num + b.num;
    return c;
  }
} dat[MAXN], tmp;
int chl[MAXN][2], fa[MAXN], top = 0, root = 0;
void zig(int nd) {
  int p = fa[nd], g = fa[p], tp = chl[p][0] != nd, tg = chl[g][0] != p;
  int son = chl[nd][tp ^ 1];
  if (g)
    chl[g][tg] = nd;
  else
    root = nd;
  if (son) fa[son] = p;
  chl[nd][tp ^ 1] = p, chl[p][tp] = son, fa[p] = nd, fa[nd] = g;
}
void splay(int nd, int tar = 0) {
  while (fa[nd] != tar) {
    int p = fa[nd], g = fa[p], tp = chl[p][0] != nd, tg = chl[g][0] != p;
    if (g == tar) {
      zig(nd);
      break;
    } else if (tp == tg)
      zig(p), zig(nd);
    else
      zig(nd), zig(nd);
  }
}
node stk[MAXN];
int d[MAXN], d_top = 0;
int stk_top = 0;
void del(int nd) {
  splay(nd);
  int pre = chl[nd][0], nxt = chl[nd][1];
  if (!nxt && !pre)
    root = 0;
  else if (!pre)
    root = chl[nd][1], fa[root] = 0;
  else if (!nxt)
    root = chl[nd][0], fa[root] = 0;
  else {
    while (chl[pre][1]) pre = chl[pre][1];
    while (chl[nxt][0]) nxt = chl[nxt][0];
    splay(pre), splay(nxt, pre), chl[nxt][0] = 0;
  }
}
void trail(int nd, node &a) {
  if (!nd)
    return;
  else {
    if (a < dat[nd])
      trail(chl[nd][0], a);
    else if (dat[nd] < a)
      trail(chl[nd][1], a);
    else {
      trail(chl[nd][0], a), trail(chl[nd][1], a);
      a = a + dat[nd];
      d[++d_top] = nd;
    }
  }
}
void insert(int &nd, const node &dt, int f = 0) {
  if (!nd)
    nd = ++top, dat[nd] = dt, fa[nd] = f, splay(nd);
  else {
    if (dt < dat[nd])
      insert(chl[nd][0], dt, nd);
    else
      insert(chl[nd][1], dt, nd);
  }
}
int query() {
  int nd = root;
  while (chl[nd][1]) nd = chl[nd][1];
  splay(nd);
  return dat[nd].num;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++)
      scanf("%d", &tmp.p_min[j]), tmp.p_max[j] = tmp.p_min[j];
    tmp.num = 1;
    trail(root, tmp);
    while (d_top) del(d[d_top--]);
    insert(root, tmp);
    printf("%d\n", query());
  }
  return 0;
}
