#include <bits/stdc++.h>
using namespace std;
inline void File() {}
template <typename T>
inline void read(T &_) {
  _ = 0;
  T __ = getchar(), ___ = 1;
  while (!isdigit(__)) {
    if (__ == '-') ___ = -1;
    __ = getchar();
  }
  while (isdigit(__)) {
    _ = (_ << 1) + (_ << 3) + (__ ^ '0');
    __ = getchar();
  }
  _ *= ___;
}
template <typename T>
inline bool Chkmax(T &_, T __) {
  return _ < __ ? _ = __, 1 : 0;
}
template <typename T>
inline bool Chkmin(T &_, T __) {
  return _ > __ ? _ = __, 1 : 0;
}
const int N = 5e4 + 1e2;
int n, k;
struct node {
  int id, siz;
  int Max[15], Min[15];
  inline void Input() {
    siz = 1;
    for (int i = 1; i <= k; i++) read(Max[i]), Min[i] = Max[i];
  }
  bool operator<(const node &ch) const {
    for (int i = 1; i <= k; i++)
      if (Max[i] > ch.Min[i]) return 0;
    return 1;
  }
  inline void Merge(const node &A) {
    for (int i = 1; i <= k; i++) {
      Min[i] = min(Min[i], A.Min[i]);
      Max[i] = max(Max[i], A.Max[i]);
    }
    siz += A.siz;
  }
} a[N];
set<node> S;
inline void Print(node A) {
  for (int i = 1; i <= k; i++) printf("%d ", A.Max[i]);
  cout << endl;
}
int main() {
  File();
  read(n), read(k);
  for (int i = 1; i <= n; i++) a[i].Input(), a[i].id = i;
  S.insert(a[1]);
  printf("%d\n", 1);
  for (int i = 2; i <= n; i++) {
    set<node>::iterator L = S.lower_bound(a[i]);
    set<node>::iterator R = S.upper_bound(a[i]);
    while (L != R) {
      a[i].Merge(*L);
      L = S.erase(L);
    }
    S.insert(a[i]);
    L = S.end();
    --L;
    printf("%d\n", (*L).siz);
  }
  return 0;
}
