#include <bits/stdc++.h>
using namespace std;
int n, k;
struct node {
  int sz;
  vector<int> m, M;
  node() {
    sz = 1;
    for (int i = 0; i < k; ++i) {
      int x;
      scanf("%d", &x);
      m.push_back(x);
      M.push_back(x);
    }
  }
  bool operator<(const node &b) const {
    for (int i = 0; i < k; ++i) {
      if (M[i] > b.m[i]) return false;
    }
    return true;
  }
  void merge(const node &nd) {
    for (int i = 0; i < k; ++i) {
      M[i] = max(M[i], nd.M[i]);
      m[i] = min(m[i], nd.m[i]);
    }
    sz += nd.sz;
  }
};
set<node> st;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    node nd = node();
    set<node>::iterator lb = st.lower_bound(nd);
    set<node>::iterator ub = st.upper_bound(nd);
    while (lb != ub) {
      nd.merge(*lb);
      st.erase(lb++);
    }
    st.insert(nd);
    printf("%d\n", (st.rbegin())->sz);
  }
  return 0;
}
