#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int a = 0, b = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') {
    b = -b;
    c = getchar();
  }
  while (isdigit(c)) {
    a = a * 10 + c - '0';
    c = getchar();
  }
  return a * b;
}
struct edge {
  int n, mx[13], mn[13], q;
} k, o;
bool operator<(edge a, edge b) {
  if (a.q == 0 && b.q == 0) return a.mx[1] > b.mx[1];
  int x = max(a.q, b.q);
  return a.mx[x] > b.mx[x];
}
set<edge> p;
set<edge>::iterator ite, mn;
int n, m;
bool king;
bool pd(edge a, edge b) {
  for (int i = 1; i <= m; i++)
    if (a.mx[i] < b.mx[i]) return 1;
  return 0;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    king = 0;
    k.n = 1;
    mn = p.end();
    for (int j = 1; j <= m; j++) k.mx[j] = k.mn[j] = read();
    for (int j = 1; j <= m; j++) {
      k.q = j;
      ite = p.lower_bound(k);
      if (ite == p.end() && !p.empty()) {
        ite--;
        if (ite->mn[j] > k.mx[j]) ite++;
      } else if (k < *ite) {
        if (ite == p.begin()) {
          king = 1;
        } else {
          ite--;
          if (ite->mn[j] > k.mx[j]) ite++;
        }
      }
      if (ite != p.end() && !king && (mn == p.end() || *ite < *mn)) mn = ite;
      if (king) break;
    }
    if (king) mn = p.begin();
    o = k;
    k.q = o.q = 0;
    while (mn != p.end()) {
      if (!pd(k, *mn)) break;
      o.n += mn->n;
      for (int j = 1; j <= m; j++) {
        o.mx[j] = max(o.mx[j], mn->mx[j]);
        o.mn[j] = min(o.mn[j], mn->mn[j]);
      }
      if (mn != p.begin()) {
        ite = mn;
        ite--;
        p.erase(mn);
        mn = ite;
        mn++;
      } else {
        p.erase(mn);
        mn = p.begin();
      }
    }
    p.insert(o);
    printf("%d\n", p.begin()->n);
  }
  return 0;
}
