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