#include <bits/stdc++.h>
using namespace std;
template <typename T>
void resize(int n, vector<T> &u) {
  u.resize(n);
}
template <typename Head, typename... Tail>
void resize(int n, Head &H, Tail &...T) {
  resize(n, H);
  resize(n, T...);
}
template <typename T>
void debug_out(T t) {
  cerr << t;
}
template <typename A, typename B>
void debug_out(pair<A, B> &u) {
  cerr << "(" << u.first << " " << u.second << ")";
}
template <typename T>
void debug_out(vector<T> &t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << ", ";
  }
}
template <typename T>
void debug_out(vector<vector<T>> &t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << endl;
  }
}
vector<char> lowchar = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                        'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                        's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
vector<char> hichar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                       'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                       'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> base_10 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
template <typename T>
string to_string(T t) {
  ostringstream ss;
  ss << t;
  return ss.str();
}
long long to_num(string t) {
  long long res = 0;
  for (int i = 0; i < (int)t.length(); i++) {
    res *= 10;
    res += t[i] - '0';
  }
  return res;
}
int n, k;
struct info {
  vector<int> l, r;
  int c = 0, sz;
  info(int _k) : sz(_k) { resize(k, l, r); }
  info operator+(const info &a) const {
    info res(sz);
    for (int i = 0; i < sz; i++) {
      res.l[i] = min(l[i], a.l[i]);
      res.r[i] = max(r[i], a.r[i]);
    }
    res.c = c + a.c;
    return res;
  }
  bool operator<(const info &a) const { return l[0] < a.l[0]; }
  bool mergeable(info a) {
    bool les = false, gre = false;
    for (int i = 0; i < sz; i++) {
      if (a.l[i] <= r[i] && a.r[i] >= l[i]) return true;
      if (a.l[i] > r[i]) gre = true;
      if (a.r[i] < l[i]) les = true;
    }
    return (les && gre);
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  set<info> cur;
  while (n--) {
    info sp(k);
    for (int i = 0; i < k; i++) {
      int u;
      cin >> u;
      sp.l[i] = u;
      sp.r[i] = u;
    }
    sp.c = 1;
    auto it = cur.lower_bound(sp);
    info aux(k);
    while (it != cur.end() && sp.mergeable(*it)) {
      if (aux.c == 0)
        aux = *it;
      else
        aux = aux + *it;
      it++;
    }
    auto cat = cur.lower_bound(sp);
    if (cat != cur.begin()) {
      cat--;
      while (true) {
        if (sp.mergeable(*cat)) {
          if (aux.c == 0)
            aux = *cat;
          else
            aux = aux + *cat;
          if (cat == cur.begin()) break;
          cat--;
        } else {
          cat++;
          break;
        }
      }
    }
    cur.erase(cat, it);
    if (aux.c != 0) sp = sp + aux;
    cur.insert(sp);
    cout << cur.rbegin()->c << endl;
  }
  return 0;
}
