#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, k;
struct Node {
  vector<int> s, b;
  int cnt = 1;
  Node() {
    s.resize(k);
    b.resize(k);
  }
  bool operator<(const Node &t) const {
    bool smaller = true;
    for (int i = 0; i < k; ++i) smaller &= b[i] < t.s[i];
    return smaller;
  }
  bool operator==(const Node &t) const {
    bool small = false, big = false;
    for (int i = 0; i < k; ++i) {
      small |= s[i] < t.b[i];
      big |= b[i] > t.s[i];
    }
    return small && big;
  }
  Node operator+(const Node &t) const {
    auto ans = *this;
    for (int i = 0; i < k; ++i) ans.b[i] = max(ans.b[i], t.b[i]);
    for (int i = 0; i < k; ++i) ans.s[i] = min(ans.s[i], t.s[i]);
    ans.cnt += t.cnt;
    return ans;
  }
};
int main() {
  cin >> n >> k;
  vector<Node> arr(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < k; ++j) cin >> arr[i].s[j];
    arr[i].b = arr[i].s;
  }
  set<Node> active;
  for (int i = 0; i < n; ++i) {
    auto it = active.lower_bound(arr[i]);
    while (it != active.end() && *it == arr[i]) {
      arr[i] = arr[i] + *it;
      active.erase(it++);
    }
    active.insert(arr[i]);
    assert(!active.empty());
    cout << active.rbegin()->cnt << '\n';
  }
}
