#include <bits/stdc++.h>
using namespace std;
const int INFTY = 20000000;
const int MAX = 50100;
const int MOD = 10000000;
void coutTab(const int *tab, int n) {
  for (int i = 0; i < n; i++) {
    cout << tab[i] << " ";
  }
  cout << "\n";
}
int n, k;
struct pwrs {
  int smax[10], smin[10];
  int size;
};
inline bool operator<(const pwrs &a, const pwrs &b) {
  return a.smin[0] < b.smin[0];
}
bool canDef(pwrs par, pwrs c) {
  for (int i = 0; i < k; i++) {
    if (par.smax[i] > c.smin[i]) return true;
  }
  return false;
}
bool canBeDef(pwrs par, pwrs c) {
  for (int i = 0; i < k; i++) {
    if (c.smax[i] > par.smin[i]) return true;
  }
  return false;
}
pwrs merge(pwrs a, pwrs b) {
  for (int i = 0; i < k; i++) {
    a.smax[i] = max(a.smax[i], b.smax[i]);
    a.smin[i] = min(a.smin[i], b.smin[i]);
  }
  a.size += b.size;
  return a;
}
int main() {
  cin >> n >> k;
  set<pwrs> com;
  pwrs par;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      cin >> par.smax[j];
      par.smin[j] = par.smax[j];
    }
    par.size = 1;
    if (i == 0) {
      com.insert(par);
      cout << 1 << "\n";
    } else {
      auto it = com.lower_bound(par);
      auto itb = it;
      if (it != com.begin()) {
        while (canBeDef(par, *prev(itb))) {
          itb = prev(itb);
          par = merge(par, *itb);
          if (itb == com.begin()) break;
        }
      }
      while (it != com.end() && canDef(par, *it)) {
        par = merge(par, *it);
        it = next(it);
      }
      if (it == com.begin()) {
        com.insert(par);
      } else {
        com.erase(itb, it);
        com.insert(par);
      }
      cout << (prev(com.end())->size) << "\n";
    }
  }
}
