#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int N = 5e4 + 7;
int n, k;
int r[N], fa[N];
int str_mn[N][11];
int str_mx[N][11];
struct cmp {
  bool operator()(const int &i, const int &j) const {
    for (int x = 0; x < k; ++x)
      if (str_mx[i][x] >= str_mn[j][x]) return false;
    return true;
  }
};
set<int, cmp> S;
int fs(int u) { return fa[u] != u ? fa[u] = fs(fa[u]) : u; }
void js(int u, int v) {
  u = fs(u), v = fs(v);
  if (u == v) return;
  if (r[u] < r[v]) swap(u, v);
  r[u] += r[v];
  fa[v] = u;
  for (int i = 0; i < k; ++i) {
    str_mn[u][i] = min(str_mn[u][i], str_mn[v][i]);
    str_mx[u][i] = max(str_mx[u][i], str_mx[v][i]);
  }
}
void solve(std::istream &in, std::ostream &out) {
  in >> n >> k;
  for (int i = 1; i <= n; ++i) r[i] = 1, fa[i] = i;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < k; ++j) {
      in >> str_mx[i][j];
      str_mn[i][j] = str_mx[i][j];
    }
    auto rang = S.equal_range(i);
    while (rang.first != rang.second) {
      js(*rang.first, i);
      rang.first = S.erase(rang.first);
    }
    S.insert(fs(i));
    out << r[*S.rbegin()] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve(cin, cout);
  return 0;
}
