#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
inline char gc() {
  static char buf[1 << 16], *p1 = buf, *p2 = buf;
  if (p1 == p2) {
    p2 = (p1 = buf) + fread(buf, 1, 1 << 16, stdin);
    if (p2 == p1) return EOF;
  }
  return *p1++;
}
template <class t>
inline t read(t &x) {
  char c = gc();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = gc();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = gc();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
int n, k;
struct node {
  int sz, ma[15], mi[15];
  node() {
    memset(ma, 0, sizeof ma);
    memset(mi, 0x3f, sizeof mi);
  }
  inline bool operator<(const node &nt) const {
    for (int i = 1; i <= k; i++)
      if (ma[i] > nt.mi[i]) return 0;
    return 1;
  }
};
set<node> s;
signed main() {
  read(n);
  read(k);
  for (int i = 1; i <= n; i++) {
    node cur;
    set<node>::iterator it;
    cur.sz = 1;
    for (int j = 1; j <= k; j++) cur.ma[j] = read(cur.mi[j]);
    while ((it = s.find(cur)) != s.end()) {
      cur.sz += it->sz;
      for (int j = 1; j <= k; j++) {
        cur.mi[j] = min(cur.mi[j], it->mi[j]);
        cur.ma[j] = max(cur.ma[j], it->ma[j]);
      }
      s.erase(it);
    }
    s.insert(cur);
    write((--s.end())->sz);
    puts("");
  }
}
