#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < 48) f |= c == '-', c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
int n, k;
struct node {
  int sz, mn[10], mx[10];
  bool operator<(const node& o) const {
    for (int i = (0), iend = (k - 1); i <= iend; ++i)
      if (mx[i] > o.mn[i]) return 0;
    return 1;
  }
};
node merge(node A, node B) {
  node res;
  res.sz = A.sz + B.sz;
  for (int i = (0), iend = (k - 1); i <= iend; ++i)
    res.mn[i] = min(A.mn[i], B.mn[i]), res.mx[i] = max(A.mx[i], B.mx[i]);
  return res;
}
multiset<node> S;
int main() {
  cin >> n >> k;
  for (int _ = (1), _end = (n); _ <= _end; ++_) {
    node cur;
    cur.sz = 1;
    for (int i = (0), iend = (k - 1); i <= iend; ++i)
      cur.mn[i] = cur.mx[i] = read();
    while (1) {
      auto it1 = S.lower_bound(cur), it2 = S.upper_bound(cur);
      if (it1 != it2) {
        cur = merge(*it1, cur), S.erase(it1);
      } else
        break;
    }
    S.insert(cur);
    printf("%d\n", S.rbegin()->sz);
  }
  return 0;
}
