#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 5;
const int K = 10;
struct power {
  int s = 1;
  vector<int> L = vector<int>(K, 0);
  vector<int> R = vector<int>(K, 0);
  bool operator<(const power &p) const {
    for (int i = 0; i < K; i++) {
      if (L[i] < p.R[i]) return 1;
    }
    return 0;
  }
  bool operator>(const power &p) const {
    for (int i = 0; i < K; i++) {
      if (R[i] > p.L[i]) return 1;
    }
    return 0;
  }
};
set<power> S;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int nn = 1; nn <= n; nn++) {
    power p;
    for (int i = 0; i < k; i++) {
      int a;
      cin >> a;
      p.L[i] = p.R[i] = a;
    }
    auto lit = S.upper_bound(p);
    auto rit = lit;
    while (rit != S.end() && p > *rit) {
      for (int i = 0; i < k; i++) {
        p.L[i] = min(p.L[i], rit->L[i]);
        p.R[i] = max(p.R[i], rit->R[i]);
      }
      p.s += rit->s;
      rit++;
    }
    S.erase(lit, rit);
    S.insert(p);
    auto it = S.end();
    it--;
    cout << it->s << "\n";
  }
  return 0;
}
