#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX, df = 2e5 + 7;
long long i, j, k, l, m, n, o, p, q, r, t, u, v, w, x, y, z;
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * y;
}
struct node {
  long long mx[20], mn[20], siz;
  node() {
    for (long long i = (0); i <= (15); ++i) mx[i] = 0, mn[i] = inf;
  }
  friend bool operator<(node st, node ch) {
    for (long long i = (1); i <= (k); ++i)
      if (st.mx[i] > ch.mn[i]) return 0;
    return 1;
  }
} a[df];
set<node> s;
set<node>::iterator it;
int main() {
  n = read(), k = read();
  for (long long i = (1); i <= (n); ++i) {
    a[i].siz = 1;
    for (long long j = (1); j <= (k); ++j) a[i].mx[j] = a[i].mn[j] = read();
    while ((it = s.find(a[i])) != s.end()) {
      a[i].siz += it->siz;
      for (long long j = (1); j <= (k); ++j) {
        a[i].mn[j] = min(a[i].mn[j], it->mn[j]);
        a[i].mx[j] = max(a[i].mx[j], it->mx[j]);
      }
      s.erase(it);
    }
    s.insert(a[i]);
    printf("%lld\n", (--s.end())->siz);
  }
}
