#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const double eps = 0.000001;
const int SZK = 11, SZ = 2e4;
int i1 = 0, i2 = 0;
struct cmp {
  int sz;
  int s[2][SZK];
  bool operator<(const cmp &r) const { return s[i1][i2] < r.s[i1][i2]; }
  bool operator>(const cmp &r) const { return s[i1][i2] > r.s[i1][i2]; }
};
struct compare {
  bool operator()(const cmp &l, const cmp &r) const {
    return l.s[i1][i2] < r.s[i1][i2];
  }
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  cmp v1, v2;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < SZK; j++) {
      v1.s[i][j] = 0;
      v2.s[i][j] = INF;
    }
  }
  set<cmp, compare> st = {v1, v2};
  for (int i13 = 0; i13 < n; i13++) {
    cmp cur;
    cur.sz = 1;
    for (int i = 0; i < k; i++) {
      cin >> cur.s[0][i];
      cur.s[1][i] = cur.s[0][i];
    }
    i1 = 1;
    i2 = 0;
    auto lit = st.upper_bound(cur);
    i1 = 0;
    auto rit = st.upper_bound(cur);
    rit--;
    for (i2 = 1; i2 < k; i2++) {
      i1 = 1;
      auto clit = st.upper_bound(cur);
      i1 = 0;
      auto crit = st.upper_bound(cur);
      crit--;
      if (*clit < *lit) lit = clit;
      if (*crit > *rit) rit = crit;
    }
    rit++;
    for (auto it = lit; it != rit;) {
      cur.sz += it->sz;
      for (int i = 0; i < k; i++) {
        cur.s[0][i] = min(cur.s[0][i], it->s[0][i]);
        cur.s[1][i] = max(cur.s[1][i], it->s[1][i]);
      }
      auto tmp = it;
      it++;
      st.erase(tmp);
    }
    i1 = 0;
    i2 = 0;
    st.insert(cur);
    auto it = st.end();
    it--;
    it--;
    cout << it->sz << endl;
  }
  return 0;
}
