#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long a[50005][15];
long long m[50005][15], M[50005][15];
set<pair<long long, long long> > S;
long long check(long long id, long long a[]) {
  bool win = true, lose = true;
  for (long long(i) = (1); (i) <= (k); (i)++) {
    if (M[id][i] > a[i]) win = false;
    if (m[id][i] < a[i]) lose = false;
  }
  if (win) return 1;
  if (lose) return -1;
  return 0;
}
long long getl(long long a[]) {
  long long ub = n + 5, lb = -5, mid;
  while (ub - lb > 1) {
    mid = (ub + lb) / 2;
    auto p = S.lower_bound(pair<long long, long long>(mid, -1e18));
    if (p == S.end() || check(p->first, a) <= 0)
      ub = mid;
    else
      lb = mid;
  }
  auto it = S.lower_bound(pair<long long, long long>(ub, -1e18));
  if (it == S.end()) return 1e18;
  return it->first;
}
long long getr(long long a[]) {
  long long ub = n + 5, lb = -5, mid;
  while (ub - lb > 1) {
    mid = (ub + lb) / 2;
    auto p = S.lower_bound(pair<long long, long long>(mid, -1e18));
    if (p != S.end() && check(p->first, a) >= 0)
      lb = mid;
    else
      ub = mid;
  }
  if (lb < -2) return -1e18;
  auto it = S.lower_bound(pair<long long, long long>(lb, -1e18));
  return it->first;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (long long(i) = (1); (i) <= (n); (i)++)
    for (long long(j) = (1); (j) <= (k); (j)++) cin >> a[i][j];
  for (long long(i) = (1); (i) <= (k); (i)++) {
    vector<long long> comp;
    for (long long(j) = (1); (j) <= (n); (j)++) comp.push_back(a[j][i]);
    sort((comp).begin(), (comp).end());
    comp.erase(unique((comp).begin(), (comp).end()), comp.end());
    for (long long(j) = (1); (j) <= (n); (j)++)
      a[j][i] =
          lower_bound((comp).begin(), (comp).end(), a[j][i]) - comp.begin();
  }
  long long id = a[1][1];
  S.insert(pair<long long, long long>(id, 1));
  for (long long(i) = (1); (i) <= (k); (i)++) M[id][i] = m[id][i] = a[1][i];
  cout << 1 << endl;
  for (long long(i) = (2); (i) <= (n); (i)++) {
    long long l = getl(a[i]), r = getr(a[i]);
    if (l > S.rbegin()->first || r < S.begin()->first) {
      long long id = a[i][1];
      S.insert(pair<long long, long long>(id, 1));
      for (long long(j) = (1); (j) <= (k); (j)++) M[id][j] = m[id][j] = a[i][j];
      cout << S.rbegin()->second << endl;
      continue;
    }
    long long sum = 1, mn[15], mx[15];
    for (long long(j) = (1); (j) <= (k); (j)++)
      mn[j] = a[i][j], mx[j] = a[i][j];
    auto it = S.lower_bound(pair<long long, long long>(l, -1e18));
    for (; it != S.end() && it->first <= r;) {
      sum += it->second;
      for (long long(j) = (1); (j) <= (k); (j)++) {
        (mn[j]) = min((mn[j]), (m[it->first][j]));
        (mx[j]) = max((mx[j]), (M[it->first][j]));
      }
      auto tmp = it;
      it++;
      S.erase(tmp);
    }
    long long id = mx[1];
    S.insert(pair<long long, long long>(id, sum));
    for (long long(j) = (1); (j) <= (k); (j)++)
      m[id][j] = mn[j], M[id][j] = mx[j];
    cout << S.rbegin()->second << endl;
  }
  return 0;
}
