#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 3, K = 10;
int n, k, m[N][K];
struct Node {
  int m1[K], m2[K], siz;
  bool operator<(const Node &rhs) const { return m1[0] < rhs.m1[0]; }
};
set<Node> ts;
bool check(const Node &n1, const Node &n2) {
  for (int i = 0; i < k; i++) {
    if (n1.m2[i] > n2.m1[i]) return true;
  }
  return false;
}
Node make_from(int i) {
  Node no;
  memcpy(no.m1, m[i], sizeof(int[K]));
  memcpy(no.m2, m[i], sizeof(int[K]));
  no.siz = 1;
  return no;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < k; j++) scanf("%d", &m[i][j]);
  for (int i = 0; i < n; i++) {
    Node no = make_from(i);
    if (ts.empty())
      ts.insert(no);
    else {
      auto it = ts.lower_bound(no);
      while (it != ts.end()) {
        if (check(no, *it)) {
          for (int u = 0; u < k; u++) {
            no.m1[u] = min(no.m1[u], it->m1[u]);
            no.m2[u] = max(no.m2[u], it->m2[u]);
          }
          no.siz += it->siz;
          ts.erase(it++);
        } else
          break;
      }
      it = ts.lower_bound(no);
      if (it != ts.begin()) {
        --it;
        while (true) {
          if (check(*it, no)) {
            for (int u = 0; u < k; u++) {
              no.m1[u] = min(no.m1[u], it->m1[u]);
              no.m2[u] = max(no.m2[u], it->m2[u]);
            }
            no.siz += it->siz;
            if (it == ts.begin()) {
              ts.erase(ts.begin());
              break;
            } else
              ts.erase(it--);
          } else
            break;
        }
      }
      ts.insert(no);
    }
    printf("%d\n", ts.rbegin()->siz);
  }
}
