#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
struct NComparator {
  bool operator()(const pair<vector<pair<int, int> >, int>& a,
                  const pair<vector<pair<int, int> >, int>& b);
};
set<pair<vector<pair<int, int> >, int>, NComparator> nodes;
int compared_skill = 0;
bool compare_lower = 0;
bool NComparator ::operator()(const pair<vector<pair<int, int> >, int>& a,
                              const pair<vector<pair<int, int> >, int>& b) {
  pair<int, int> ap = a.first[compared_skill];
  pair<int, int> bp = b.first[compared_skill];
  if (compare_lower)
    return ap.first < bp.first;
  else
    return ap.second < bp.second;
}
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 0; i < (N); ++i) {
    pair<vector<pair<int, int> >, int> n(vector<pair<int, int> >(K), 1);
    for (int j = 0; j < (K); ++j) {
      int a;
      scanf("%d", &a);
      n.first[j] = {a, a};
    }
    set<pair<vector<pair<int, int> >, int>, NComparator>::iterator
        lowest = nodes.end(),
        highest = nodes.begin();
    for (int j = 0; j < (K); ++j) {
      compared_skill = j;
      compare_lower = false;
      auto it = nodes.lower_bound(n);
      if (lowest == nodes.end()) {
        lowest = it;
      } else if (it != nodes.end() && *it < *lowest) {
        lowest = it;
      }
      compare_lower = true;
      it = nodes.lower_bound(n);
      if (it == nodes.end()) {
        highest = it;
      } else if (highest != nodes.end() && *highest < *it) {
        highest = it;
      }
    }
    for (auto it = lowest; it != highest; ++it) {
      n.second += it->second;
      for (int j = 0; j < (K); ++j) {
        n.first[j].first = min(n.first[j].first, it->first[j].first);
        n.first[j].second = max(n.first[j].second, it->first[j].second);
      }
    }
    nodes.erase(lowest, highest);
    nodes.insert(n);
    printf("%d\n", nodes.rbegin()->second);
  }
}
