#include <bits/stdc++.h>
using namespace std;
int n, k, a, hi, t;
vector<int> v, w, u, first;
set<pair<int, int> > s[11], hs[11];
bool f1, f2;
map<int, vector<int> > lo;
map<int, vector<int> > hii;
map<int, int> sz;
void check(int S) {
  hi = 0;
  f1 = 1;
  for (int l = 0; l < k; ++l) {
    if (s[l].lower_bound(make_pair(v[l], 0)) == s[l].begin()) continue;
    t = (--s[l].lower_bound(make_pair(v[l], 0)))->second;
    w = hii[t];
    f2 = 1;
    for (int l = 0; l < k; ++l) {
      if (w[l] > v[l]) f2 = 0;
    }
    if (f2) continue;
    f1 = 0;
    hi = max(hi, t);
  }
  if (f1) {
    lo[v[0]] = v;
    hii[v[0]] = u;
    sz[v[0]] = S;
    for (int l = 0; l < k; ++l) {
      s[l].insert(make_pair(v[l], v[0]));
    }
  } else {
    S += sz[hi];
    w = lo[hi];
    first = hii[hi];
    lo.erase(hi);
    hii.erase(hi);
    sz.erase(hi);
    for (int l = 0; l < k; ++l) {
      s[l].erase(make_pair(w[l], w[0]));
    }
    for (int l = 0; l < k; ++l) {
      v[l] = min(w[l], v[l]);
      u[l] = max(u[l], first[l]);
    }
    check(S);
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  while (n--) {
    v.clear();
    for (int l = 0; l < k; ++l) {
      cin >> a;
      v.push_back(a);
    }
    u = v;
    check(1);
    printf("%i\n", (--sz.end())->second);
  }
  return 0;
}
