#include <bits/stdc++.h>
using namespace std;
int const N = int(1e5) + 7;
int const mod = int(1e9) + 7;
int k;
struct chemp {
  int cnt = 1;
  int mi[10];
  int ma[10];
  void show() const {
    cout << cnt << " ";
    for (int i = 0; i < k; ++i) {
      cout << "(" << mi[i] << "," << ma[i] << ") ";
    }
    cout << endl;
  }
};
ostream &operator<<(ostream &stream, const chemp &a) {
  a.show();
  return stream;
}
bool operator<(const chemp &a, const chemp &b) {
  for (int i = 0; i < k; ++i) {
    if (a.ma[i] > b.mi[i]) {
      return false;
    }
  }
  return true;
}
bool operator==(const chemp &a, const chemp &b) {
  bool fl1 = false, fl2 = false;
  for (int i = 0; i < k; ++i) {
    if (a.ma[i] > b.mi[i]) {
      fl1 = true;
    }
    if (a.mi[i] < b.ma[i]) {
      fl2 = true;
    }
  }
  return fl1 && fl2;
}
int main() {
  ios_base::sync_with_stdio(false);
  ifstream in("input.txt");
  int n;
  cin >> n >> k;
  set<chemp> ms;
  for (int i = 0; i < n; ++i) {
    chemp cur;
    for (int j = 0; j < k; ++j) {
      cin >> cur.mi[j];
      cur.ma[j] = cur.mi[j];
    }
    auto it = ms.find(cur);
    while (it != ms.end()) {
      chemp tmp = *it;
      ms.erase(it);
      for (int j = 0; j < k; ++j) {
        cur.mi[j] = min(tmp.mi[j], cur.mi[j]);
        cur.ma[j] = max(tmp.ma[j], cur.ma[j]);
      }
      cur.cnt += tmp.cnt;
      it = ms.find(cur);
    }
    ms.insert(cur);
    it = ms.end();
    --it;
    cout << it->cnt << endl;
  }
  return 0;
}
