#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 7;
const int M = 10;
int n, K, s[M];
struct Node {
  int num, mn[M], mx[M];
  bool operator<(const Node &p) const {
    for (int i = (0); i < (K); ++i)
      if (mx[i] > p.mn[i]) return false;
    return true;
  }
};
set<Node> S;
int main() {
  scanf("%d%d", &n, &K);
  for (int _n = (0); _n < (n); ++_n) {
    for (int i = (0); i < (K); ++i) scanf("%d", s + i);
    Node now;
    now.num = 1;
    for (int i = (0); i < (K); ++i) now.mn[i] = now.mx[i] = s[i];
    auto L = S.lower_bound(now);
    auto R = S.upper_bound(now);
    while (L != R) {
      now.num += L->num;
      for (int i = (0); i < (K); ++i) {
        now.mn[i] = min(now.mn[i], L->mn[i]);
        now.mx[i] = max(now.mx[i], L->mx[i]);
      }
      auto tmp = L++;
      S.erase(tmp);
    }
    S.insert(now);
    auto last = S.end();
    --last;
    printf("%d\n", last->num);
  }
  return 0;
}
