#include <bits/stdc++.h>
using namespace std;
int n, k;
struct Conjunto {
  int L[10];
  int H[10];
  int size;
  char type;
};
void print(Conjunto C) {
  for (int i = 0; i < k; i++) cout << C.L[i] << " ";
  cout << endl;
  for (int i = 0; i < k; i++) cout << C.H[i] << " ";
  cout << endl;
  cout << C.size << " " << C.type << endl;
}
bool operator<(Conjunto Ca, Conjunto Cb) {
  char q = Ca.type + Cb.type;
  if (Ca.H[q] < Cb.H[q]) return true;
  return false;
}
int main() {
  scanf("%d %d", &n, &k);
  set<Conjunto> S;
  for (int i = 0; i < n; i++) {
    Conjunto *c = new Conjunto();
    c->size = 1;
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      c->L[j] = x;
      c->H[j] = x;
    }
    Conjunto C = *c;
    if (S.size() == 0) {
      S.insert(C);
    } else {
      set<Conjunto>::iterator lowest_top = S.end();
      set<Conjunto>::iterator highest_bottom = S.end();
      for (int j = 0; j < k; j++) {
        C.type = j;
        set<Conjunto>::iterator top = S.upper_bound(C);
        if (lowest_top == S.end()) {
          lowest_top = top;
        } else if (top != S.end()) {
          if (*top < *lowest_top) {
            lowest_top = top;
          }
        }
        set<Conjunto>::iterator bottom = top;
        if (bottom != S.begin()) {
          if (bottom == S.end() || bottom->L[j] > C.H[j]) {
            bottom--;
          }
        } else {
          if (bottom->L[j] > C.H[j]) {
            bottom = S.end();
          }
        }
        if (bottom != S.end()) {
          if (highest_bottom == S.end()) {
            highest_bottom = bottom;
          } else {
            if (*highest_bottom < *bottom) highest_bottom = bottom;
          }
        }
      }
      C.type = 0;
      if (lowest_top != S.end() && highest_bottom != S.end()) {
        if (*highest_bottom < *lowest_top) {
        } else {
          highest_bottom++;
          for (set<Conjunto>::iterator IT = lowest_top; IT != highest_bottom;
               IT++) {
            for (int j = 0; j < k; j++) {
              C.L[j] = min(C.L[j], IT->L[j]);
              C.H[j] = max(C.H[j], IT->H[j]);
            }
            C.size += IT->size;
          }
          S.erase(lowest_top, highest_bottom);
        }
      }
      S.insert(C);
    }
    set<Conjunto>::iterator it = S.end();
    it--;
    printf("%d\n", it->size);
  }
  return 0;
}
