#include <bits/stdc++.h>
using namespace std;
const int maxn = 50000 + 10;
const int K = 12;
int n, k;
struct band {
  int siz;
  int maxi[K], mini[K];
} sp[maxn];
bool operator<(band a, band b) {
  int flag = 0;
  for (int i = 1; i <= k; i++) {
    if (a.maxi[i] > b.mini[i]) flag = 1;
  }
  return !flag;
}
band operator+(band a, band b) {
  a.siz = a.siz + b.siz;
  for (int i = 1; i <= k; i++) {
    a.maxi[i] = max(a.maxi[i], b.maxi[i]);
    a.mini[i] = min(a.mini[i], b.mini[i]);
  }
  return a;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= k; j++)
      scanf("%d", &sp[i].maxi[j]), sp[i].mini[j] = sp[i].maxi[j], sp[i].siz = 1;
  set<band> S;
  for (int i = 1; i <= n; i++) {
    set<band>::iterator it1, it2, it;
    it1 = S.lower_bound(sp[i]), it2 = S.upper_bound(sp[i]);
    band now = sp[i];
    vector<set<band>::iterator> need;
    for (it = it1; it != it2; it++) {
      if (it == S.end()) break;
      now = now + *it;
      need.push_back(it);
    }
    for (int i = 0; i < need.size(); i++) {
      S.erase(need[i]);
    }
    S.insert(now);
    printf("%d\n", (*(--S.end())).siz);
  }
  return 0;
}
