#include <bits/stdc++.h>
using namespace std;
int kind;
typedef struct nd {
  int p[10][2], cnt;
  bool operator<(nd t) const { return this->p[kind][1] > t.p[kind][1]; }
} cmpn;
typedef struct nd2 {
  bool exs;
  set<cmpn>::iterator pt;
  cmpn operator*() { return *pt; }
  nd2 operator=(int x) {
    if (x == -1) {
      exs = 0;
    }
    return *this;
  }
  nd2 operator=(set<cmpn>::iterator x) {
    pt = x;
    exs = 1;
    return *this;
  }
  set<cmpn>::iterator operator->() { return pt; }
  bool operator==(set<cmpn>::iterator x) { return exs && x == pt; }
  bool operator==(nd2 x) {
    if (!exs) {
      return !x.exs;
    } else {
      return x.exs && pt == x.pt;
    }
  }
  bool operator==(int x) {
    if (x == -1) {
      return !exs;
    }
    return exs;
  }
  bool operator!=(nd2 x) { return !(*this == x); }
  bool operator!=(set<cmpn>::iterator x) { return !(*this == x); }
  bool operator!=(int x) { return !(*this == x); }
  nd2 operator--(int) {
    pt--;
    return *this;
  }
  nd2 operator++(int) {
    pt++;
    return *this;
  }
} cmpnit;
int v[10];
set<cmpn> S;
int main() {
  int n, k, i, j;
  cmpn tmp;
  scanf("%d%d", &n, &k);
  S.clear();
  for (i = 0; i < n; i++) {
    cmpnit high, low;
    high = S.end();
    low = -1;
    for (j = 0; j < k; j++) {
      scanf("%d", v + j);
      tmp.p[j][1] = v[j];
      tmp.p[j][0] = v[j];
      kind = j;
      cmpnit it;
      it = S.upper_bound(tmp);
      cmpnit tmpit = it;
      if (it == S.end() || it->p[j][0] < v[j]) {
        if (tmpit == S.begin())
          tmpit = -1;
        else
          tmpit--;
      }
      if (high == S.end() || (it != S.end() && *it < *high)) high = it;
      if (low == -1 || (tmpit != -1 && *low < *tmpit)) low = tmpit;
    }
    tmp.cnt = 1;
    if (low == -1)
      low = S.begin();
    else
      low++;
    for (auto it = high; it != low; it++) {
      tmp.cnt += it->cnt;
      for (j = 0; j < k; j++) {
        tmp.p[j][0] = max(tmp.p[j][0], it->p[j][0]);
        tmp.p[j][1] = min(tmp.p[j][1], it->p[j][1]);
      }
    }
    S.erase(high.pt, low.pt);
    S.insert(tmp);
    printf("%d\n", S.begin()->cnt);
  }
  return 0;
}
