#include <bits/stdc++.h>
using namespace std;
struct Interval {
  int beg, end, who;
  bool operator<(const Interval &in) const { return end < in.end; }
};
int N, K, s[50000 + 5][10 + 5], num[50000 + 5], pa[50000 + 5];
set<Interval> loser[10 + 5];
Interval winner[10 + 5], si[50000 + 5][10 + 5];
bool lowlv(int id) {
  int *p = s[id];
  for (int i = 0; i < K; i++) {
    if (p[i] > winner[i].beg) return false;
  }
  return true;
}
bool highlv(int id) {
  int *p = s[id];
  for (int i = 0; i < K; i++) {
    if (p[i] < winner[i].end) return false;
  }
  return true;
}
void add(int id) {
  if (lowlv(id)) {
    for (int i = 0; i < K; i++) loser[i].insert(si[id][i]);
    return;
  }
  if (highlv(id)) {
    for (int i = 0; i < K; i++) {
      loser[i].insert(winner[i]);
      si[winner[i].who][i] = winner[i];
      winner[i] = si[id][i];
    }
    return;
  }
  pa[id] = winner[0].who;
  num[winner[0].who]++;
  while (true) {
    bool update = false;
    for (int i = 0; i < K; i++) {
      winner[i].beg = min(winner[i].beg, s[id][i]);
      winner[i].end = max(winner[i].end, s[id][i]);
      while (!loser[i].empty()) {
        const Interval &cur = *loser[i].rbegin();
        if (cur.end < winner[i].beg) break;
        if (pa[cur.who] == cur.who) {
          update = true;
          pa[cur.who] = winner[i].who;
          num[winner[i].who] += num[cur.who];
          for (int j = 0; j < K; j++) {
            winner[j].beg = min(winner[j].beg, si[cur.who][j].beg);
          }
        }
        loser[i].erase(--loser[i].end());
      }
    }
    if (!update) break;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    num[i] = 1;
    pa[i] = i;
    for (int j = 0; j < K; j++) {
      cin >> s[i][j];
      si[i][j] = {s[i][j], s[i][j], i};
    }
  }
  for (int i = 0; i < K; i++) winner[i] = si[0][i];
  cout << 1 << '\n';
  for (int i = 1; i < N; i++) {
    add(i);
    cout << num[winner[0].who] << '\n';
  }
  return 0;
}
