#include <bits/stdc++.h>
using namespace std;
const int N = 50050;
int n, k;
set<pair<vector<pair<int, int> >, int> > s;
void update(vector<pair<int, int> > &a, const vector<pair<int, int> > &b) {
  for (int i = (0); i <= (k - 1); i++) {
    a[i].first = min(a[i].first, b[i].first);
    a[i].second = max(a[i].second, b[i].second);
  }
}
bool cmp(vector<pair<int, int> > a, vector<pair<int, int> > b) {
  for (int i = (0); i <= (k - 1); i++)
    if (a[i].second > b[i].first) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  s = {{vector<pair<int, int> >(k, {0, 0}), 0},
       {vector<pair<int, int> >(k, {1e9 + 10, 1e9 + 10}), 0}};
  for (int i = (1); i <= (n); i++) {
    vector<pair<int, int> > now(k);
    for (int j = (0); j <= (k - 1); j++) {
      int x;
      cin >> x;
      now[j].first = now[j].second = x;
    }
    int num = 1;
    auto it = s.lower_bound({now, 0});
    auto rit = it, lit = it;
    while (cmp(now, rit->first)) {
      update(now, rit->first);
      num += rit->second;
      rit++;
    }
    lit--;
    while (cmp(lit->first, now)) {
      update(now, lit->first);
      num += lit->second;
      lit--;
    }
    lit++;
    s.erase(lit, rit);
    s.insert({now, num});
    it = s.end();
    it--;
    it--;
    cout << it->second << endl;
  }
  return 0;
}
