#include <bits/stdc++.h>
using namespace std;
struct pt {
  int num;
  vector<int> mi, ma;
  pt(int num = -1) : num(num){};
  pt(int num, vector<int> mi, vector<int> ma) : num(num), mi(mi), ma(ma){};
  void add(pt a) {
    num += a.num;
    for (int i = 0; i < mi.size(); ++i) {
      mi[i] = min(mi[i], a.mi[i]);
      ma[i] = max(ma[i], a.ma[i]);
    }
  }
};
bool operator<(pt a, pt b) {
  for (int i = 0; i < a.ma.size(); ++i)
    if (a.ma[i] > b.mi[i]) return false;
  return true;
}
int inf = 1e9 + 1;
int n, k;
vector<int> v;
pt p, cur;
map<int, pt> mi[10], ma[10];
map<int, pt>::iterator it, lim;
void ad(pt& a) {
  for (int h = 0; h < k; ++h) {
    mi[h][a.mi[h]] = a;
    ma[h][a.ma[h]] = a;
  }
}
void er(pt& a) {
  for (int h = 0; h < k; ++h) {
    mi[h].erase(a.mi[h]);
    ma[h].erase(a.ma[h]);
  }
}
void add(pt& a) {
  if (ma[0].empty()) {
    ad(a);
    return;
  }
  bool fl = true;
  bool ff = false;
  for (int h = 0; h < k; ++h) {
    if (a.mi[h] < (--ma[h].end())->first) fl = false;
    if (a.ma[h] > (--mi[h].end())->first) ff = true;
  }
  if (fl) {
    ad(a);
    return;
  }
  pt l, r;
  for (int h = 0; h < k; ++h) {
    it = ma[h].lower_bound(a.mi[h]);
    if (it != ma[h].end() && (l.num == -1 || it->second.ma[h] < l.ma[h]))
      l = it->second;
    if (ff) continue;
    it = mi[h].upper_bound(a.ma[h]);
    if (r.num == -1 || it->second.ma[h] > r.ma[h]) r = it->second;
  }
  vector<pt> del;
  lim = (ff ? mi[0].end() : mi[0].find(r.mi[0]));
  for (it = mi[0].find(l.mi[0]); it != lim; ++it) {
    a.add(it->second);
    del.push_back(it->second);
  }
  for (int i = 0; i < del.size(); ++i) er(del[i]);
  ad(a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  v.resize(k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < k; ++j) cin >> v[j];
    pt p(1, v, v);
    if (!i)
      cur = p;
    else if (cur < p) {
      swap(cur, p);
      add(p);
    } else if (p < cur)
      add(p);
    else {
      add(p);
      er(p);
      cur.add(p);
    }
    cout << cur.num << "\n";
  }
  return 0;
}
