#include <bits/stdc++.h>
using namespace std;
int n, m;
struct nodeS {
  vector<int> minV;
  vector<int> maxV;
  int N;
  bool operator<(const nodeS& X) const {
    for (int i = 0; i < m; i++) {
      if (maxV[i] > X.maxV[i]) {
        return false;
      }
    }
    return true;
  }
};
set<nodeS> s;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    nodeS now;
    vector<int> V;
    for (int j = 0; j < m; j++) {
      int y;
      scanf("%d", &y);
      V.push_back(y);
      now.minV.push_back(y);
      now.maxV.push_back(y);
    }
    now.N = 1;
    auto x = s.lower_bound(now);
    while (x != s.end()) {
      bool isNowWin = false;
      for (int i = 0; i < m; i++) {
        if (V[i] > x->minV[i]) {
          isNowWin = true;
          break;
        }
      }
      if (isNowWin) {
        for (int i = 0; i < m; i++) {
          now.minV[i] = min(now.minV[i], x->minV[i]);
          now.maxV[i] = max(now.maxV[i], x->maxV[i]);
        }
        now.N += x->N;
        x = s.erase(x);
      } else
        break;
    }
    s.insert(now);
    printf("%d\n", s.rbegin()->N);
  }
}
