#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 100;
int n, k;
struct node {
  int sz;
  int mn[15], mx[15];
  void init(int a) {
    sz = 0;
    for (int i = 1; i <= k; i++) {
      mx[i] = mn[i] = a;
    }
  }
  void unit(node a) {
    sz += a.sz;
    for (int i = 1; i <= k; i++) {
      mn[i] = min(mn[i], a.mn[i]);
      mx[i] = max(mx[i], a.mx[i]);
    }
  }
  bool operator<(const node& p) const {
    for (int i = 1; i <= k; i++) {
      if (mx[i] > p.mn[i]) return false;
    }
    return true;
  }
};
set<node> s;
vector<set<node>::iterator> del;
int main() {
  scanf("%d %d", &n, &k);
  node now;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) scanf("%d", &now.mn[j]), now.mx[j] = now.mn[j];
    now.sz = 1;
    set<node>::iterator l, r, iter;
    r = s.upper_bound(now);
    l = s.lower_bound(now);
    for (iter = l; iter != r; iter++) {
      now.unit(*iter);
      del.push_back(iter);
    }
    for (int j = 0; j < del.size(); j++) {
      s.erase(del[j]);
    }
    del.clear();
    s.insert(now);
    iter = s.end();
    iter--;
    printf("%d\n", iter->sz);
  }
  return 0;
}
