#include <bits/stdc++.h>
using namespace std;
int k;
struct node {
  int ma[10];
  int mi[10];
  int cnt = 1;
  bool operator==(const node &a) const {
    bool f0 = false, f1 = false;
    for (int i = 0; i < k; ++i) {
      if (ma[i] > a.mi[i]) f0 = true;
      if (mi[i] < a.ma[i]) f1 = true;
    }
    if (f0 & f1) return true;
    return false;
  }
  bool operator<(const node &a) const {
    for (int i = 0; i < k; ++i) {
      if (ma[i] > a.mi[i]) return false;
    }
    return true;
  }
};
int n;
set<node> se;
node cur;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < k; ++j) {
      scanf("%d", &cur.mi[j]);
      cur.ma[j] = cur.mi[j];
    }
    cur.cnt = 1;
    set<node>::iterator it = se.find(cur);
    while (it != se.end()) {
      for (int i = 0; i < k; ++i) {
        cur.mi[i] = min(cur.mi[i], it->mi[i]);
        cur.ma[i] = max(cur.ma[i], it->ma[i]);
      }
      cur.cnt += it->cnt;
      se.erase(it);
      it = se.find(cur);
    }
    se.insert(cur);
    it = se.end();
    --it;
    printf("%d\n", it->cnt);
  }
  return 0;
}
