#include <bits/stdc++.h>
using namespace std;
struct node {
  int M;
  int id;
  int mi[10], ma[10];
};
int N, K;
struct node S[50505];
struct node* winner;
set<pair<int, int>> cand[10];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  scanf("%d%d", &N, &K);
  for (i = 0; i < (N); i++) {
    S[i].M = 1;
    S[i].id = i;
    for (j = 0; j < (K); j++) {
      scanf("%d", &x);
      S[i].mi[j] = S[i].ma[j] = x;
    }
    if (i == 0) {
      winner = &S[0];
    } else {
      int allwin = 1, alllose = 1;
      for (j = 0; j < (K); j++) {
        if (S[i].mi[j] < winner->ma[j]) allwin = 0;
        if (S[i].ma[j] > winner->mi[j]) alllose = 0;
      }
      if (allwin == 1) {
        for (j = 0; j < (K); j++) cand[j].insert({winner->ma[j], winner->id});
        winner = &S[i];
      } else if (alllose == 1) {
        for (j = 0; j < (K); j++) cand[j].insert({S[i].ma[j], S[i].id});
      } else {
        winner->M++;
        for (j = 0; j < (K); j++) {
          winner->mi[j] = min(winner->mi[j], S[i].mi[j]);
          winner->ma[j] = max(winner->ma[j], S[i].ma[j]);
        }
        int up = 1;
        while (up) {
          up = 0;
          for (j = 0; j < (K); j++)
            if (cand[j].size() && cand[j].rbegin()->first > winner->mi[j]) {
              x = cand[j].rbegin()->second;
              break;
            }
          if (j < K) {
            up = 1;
            winner->M += S[x].M;
            for (j = 0; j < (K); j++) {
              cand[j].erase({S[x].ma[j], x});
              winner->mi[j] = min(winner->mi[j], S[x].mi[j]);
              winner->ma[j] = max(winner->ma[j], S[x].ma[j]);
            }
          }
        }
      }
    }
    (void)printf("%d\n", winner->M);
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
