#include <bits/stdc++.h>
using namespace std;
const long long inf = 9.2e18;
const int maxn = 2e3 + 70;
const int INF = 2.1e9;
const int maxm = 1e6 + 70;
const int MOD = 1e9 + 7;
const double eps = 1e-7;
const double PI = acos(-1.0);
int n, m, k;
struct cmp {
  bool operator()(const vector<pair<int, int> >& a,
                  const vector<pair<int, int> >& b) const {
    for (int i = 0; i < a.size(); i++) {
      if (a[i].first > b[i].second) return 0;
    }
    return 1;
  }
};
cmp F;
map<vector<pair<int, int> >, int, cmp> M;
int main() {
  while (cin >> n >> k) {
    M.clear();
    for (int i = 0; i < n; i++) {
      int cnt = 1;
      vector<pair<int, int> > x(k);
      for (int j = 0; j < k; j++) {
        scanf("%d", &x[j].first);
        x[j].second = x[j].first;
      }
      auto it = M.lower_bound(x), it2 = M.upper_bound(x);
      while (it != it2) {
        cnt += it->second;
        for (int j = 0; j < k; j++) {
          x[j].first = max(x[j].first, it->first[j].first);
          x[j].second = min(x[j].second, it->first[j].second);
        }
        it = M.erase(it);
      }
      M[x] = cnt;
      printf("%d\n", (--M.end())->second);
    }
  }
  return 0;
}
