#include <bits/stdc++.h>
using namespace std;
const int maxn = 50000 + 10;
int find(vector<int>& v, int x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin() + 1;
}
vector<int> val[11];
int d[maxn][11], k;
int loseId;
vector<vector<int>> LoseM, LoseQ;
vector<int> LoseNum;
set<pair<int, int>> SetM[11], SetQ[11];
void init() {
  loseId = 0;
  LoseM.clear(), LoseQ.clear(), LoseNum.clear();
  for (int i = 0; i <= 10; i++) SetM[i].clear(), SetQ[i].clear();
}
void insert(vector<int>& Max, vector<int>& QQ, int people) {
  int find = -1;
  for (int j = 0; j < k && SetQ[j].size(); j++) {
    auto it = SetQ[j].lower_bound({Max[j], 1});
    it--;
    if (it->first < Max[j] && it != SetQ[j].end()) {
      for (int x = 0; x < k; x++)
        if (LoseM[it->second][x] > QQ[x]) {
          find = it->second;
        }
      if (find != -1) {
        break;
      }
    }
  }
  if (find != -1) {
    for (int j = 0; j < k; j++) {
      SetM[j].erase({LoseM[find][j], find});
      SetQ[j].erase({LoseQ[find][j], find});
      LoseM[find][j] = max(LoseM[find][j], Max[j]);
      LoseQ[find][j] = min(LoseQ[find][j], QQ[j]);
    }
    for (int j = 0; j < k; j++) {
      SetM[j].insert({LoseM[find][j], find});
      SetQ[j].insert({LoseQ[find][j], find});
    }
    LoseNum[find] += people;
  } else {
    LoseM.push_back(Max);
    LoseQ.push_back(QQ);
    LoseNum.push_back(people);
    for (int j = 0; j < k; j++)
      SetM[j].insert({Max[j], loseId}), SetQ[j].insert({QQ[j], loseId});
    loseId++;
  }
}
int main() {
  int n;
  while (scanf("%d%d", &n, &k) == 2) {
    init();
    for (int i = 0; i < k; i++) val[i].clear();
    for (int i = 0; i < n; i++)
      for (int j = 0; j < k; j++) {
        scanf("%d", &d[i][j]);
        val[j].push_back(d[i][j]);
      }
    for (int i = 0; i < k; i++) sort(val[i].begin(), val[i].end());
    vector<int> Max, QQV;
    int pre = 0;
    int ans = 1;
    for (int i = 0; i < k; i++) {
      int tmp = find(val[i], d[0][i]);
      Max.push_back(tmp);
      QQV.push_back(tmp);
    }
    printf("%d\n", ans);
    for (int i = 1; i < n; i++) {
      vector<int> D;
      for (int j = 0; j < k; j++) D.push_back(find(val[j], d[i][j]));
      int cnt = 0, cnt2 = 0;
      for (int j = 0; j < k; j++) {
        if (D[j] > QQV[j]) cnt++;
        if (D[j] > Max[j]) cnt2++;
      }
      if (cnt == 0)
        insert(D, D, 1);
      else if (cnt2 == k) {
        insert(Max, QQV, ans);
        ans = 1;
        for (int j = 0; j < k; j++) Max[j] = QQV[j] = D[j];
      } else {
        ans++;
        for (int j = 0; j < k; j++) {
          QQV[j] = min(QQV[j], D[j]);
          Max[j] = max(Max[j], D[j]);
        }
        for (int j = 0; j < k; j++) {
          vector<int> removeId;
          for (auto it = SetM[j].rbegin(); it != SetM[j].rend(); it++) {
            if (it->first > QQV[j]) {
              removeId.push_back(it->second);
              QQV[j] = min(QQV[j], LoseQ[it->second][j]);
              Max[j] = max(Max[j], LoseM[it->second][j]);
            } else
              break;
          }
          for (auto id : removeId) {
            ans += LoseNum[id];
            for (int j = 0; j < k; j++) {
              SetM[j].erase({LoseM[id][j], id});
              SetQ[j].erase({LoseQ[id][j], id});
              QQV[j] = min(QQV[j], LoseQ[id][j]);
              Max[j] = max(Max[j], LoseM[id][j]);
            }
          }
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
