#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 62);
const int inf = (1 << 30);
const int nmax = 1e5 + 50;
const long long mod = 1e9 + 7;
using namespace std;
int n, k, i;
struct st {
  pair<int, int> a[12];
  int sz;
} x, y;
bool operator<(st x, st y) {
  for (int i = 1; i <= k; i++)
    if (x.a[i].second > y.a[i].first) return 0;
  return 1;
}
set<st> s;
set<st>::iterator it;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> k;
  while (n--) {
    for (i = 1; i <= k; i++) {
      cin >> x.a[i].first;
      x.a[i].second = x.a[i].first;
    }
    x.sz = 1;
    it = s.lower_bound(x);
    while (it != s.upper_bound(x)) {
      it = s.lower_bound(x);
      y = (*it);
      for (i = 1; i <= k; i++) {
        x.a[i].first = min(x.a[i].first, y.a[i].first);
        x.a[i].second = max(x.a[i].second, y.a[i].second);
      }
      x.sz += y.sz;
      s.erase(it);
      it = s.lower_bound(x);
    }
    s.insert(x);
    x = *s.rbegin();
    cout << x.sz << endl;
  }
  return 0;
}
