#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int a[50100][12];
set<pair<int, unsigned short int> > s[12];
set<pair<int, unsigned short int> > S;
int p[50100];
int sz[50100];
int pr(int v) {
  if (v == p[v]) {
    return v;
  }
  p[v] = pr(p[v]);
  return p[v];
}
void unite(int x, int y) {
  x = pr(x);
  y = pr(y);
  if (x == y) {
    return;
  }
  if (sz[x] < sz[y]) {
    swap(x, y);
  }
  sz[x] += sz[y];
  p[y] = x;
}
void add_edge(int i, int j) {
  i = pr(i);
  j = pr(j);
  if (a[i][0] <= a[j][0]) {
    return;
  }
  set<pair<int, unsigned short int> >::iterator it1 =
      S.find(make_pair(a[j][0], j));
  set<pair<int, unsigned short int> >::iterator it2 =
      S.find(make_pair(a[i][0], i));
  vector<int> path;
  for (; it1 != it2; it1++) {
    path.push_back(it1->second);
  }
  for (int k = 0; k < (int)(path.size()); ++k) {
    int cur = path[k];
    unite(cur, i);
    S.erase(S.find(make_pair(a[cur][0], cur)));
  }
  S.erase(S.find(make_pair(a[i][0], i)));
  i = pr(i);
  S.insert(make_pair(a[i][0], i));
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(k); ++j) {
      cin >> a[i][j];
      a[i][j] *= -1;
    }
    p[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < (int)(n); ++i) {
    S.insert(make_pair(a[i][0], i));
    for (int j = 0; j < (int)(k); ++j) {
      int x = a[i][j];
      if (!i) {
        s[j].insert(make_pair(x, i));
        continue;
      }
      set<pair<int, unsigned short int> >::iterator it2 =
          s[j].lower_bound(make_pair(x, 0));
      set<pair<int, unsigned short int> >::iterator it1 = it2;
      if (it1 == s[j].begin()) {
        it1 = s[j].end();
      } else {
        --it1;
      }
      if (it1 != s[j].end()) {
        add_edge(it1->second, i);
      }
      if (it2 != s[j].end()) {
        add_edge(i, it2->second);
      }
      s[j].insert(make_pair(x, i));
    }
    cout << sz[pr(S.begin()->second)] << endl;
  }
  return 0;
}
