#include <bits/stdc++.h>
using namespace std;
int const K = 12;
int const N = 5e4 + 123;
int n, k;
int s[N][K], maxi[N][K], mini[N][K];
int ans[N];
int cnt[N];
struct Player {
  int id, v;
  Player(){};
  Player(int id, int v) : id(id), v(v){};
  bool operator<(const Player &a) const {
    if (v != a.v) return v < a.v;
    return id < a.id;
  };
};
set<Player> t[K];
Player winner = Player(-1, -1);
void pushplayer(int id) {
  for (int i = 0; i < k; ++i) {
    t[i].insert(Player(id, maxi[id][i]));
  }
}
void remove(int id) {
  for (int i = 0; i < k; ++i) {
    t[i].erase(Player(id, maxi[id][i]));
  }
}
void merge(int ida, int idb) {
  int idc = min(ida, idb);
  winner.id = idc;
  cnt[idc] = cnt[ida] + cnt[idb];
  for (int i = 0; i < k; ++i) {
    mini[idc][i] = min(mini[idb][i], mini[ida][i]);
    maxi[idc][i] = max(maxi[idb][i], maxi[ida][i]);
  }
}
bool canbeat(int ida, int idb) {
  for (int i = 0; i < k; ++i)
    if (maxi[ida][i] > mini[idb][i]) return true;
  return false;
}
void solve() {
  ans[0] = 1;
  winner = Player(0, -1);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < k; ++j) mini[i][j] = maxi[i][j] = s[i][j];
  for (int i = 0; i < n; ++i) cnt[i] = 1;
  for (int i = 1; i < n; ++i) {
    bool f;
    if (canbeat(i, winner.id)) {
      if (canbeat(winner.id, i)) {
        merge(i, winner.id);
        f = true;
      } else {
        pushplayer(winner.id);
        winner = Player(i, -1);
        f = false;
      }
    } else {
      pushplayer(i);
      f = false;
    }
    while (f) {
      f = false;
      Player bf = Player(-1, -1);
      for (int j = 0; j < k; ++j) {
        if ((int)(t[j].size())) {
          set<Player>::iterator it = t[j].end();
          --it;
          Player b = (*it);
          if (canbeat(b.id, winner.id)) {
            bf = b;
            f = true;
            break;
          }
        }
      }
      if (!f) break;
      remove(bf.id);
      merge(winner.id, bf.id);
    }
    ans[i] = cnt[winner.id];
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < k; ++j) scanf("%d", &s[i][j]);
  solve();
  for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}
