#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1, ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
int K;
struct node {
  int maxn[11], minn[11];
  int sz;
  bool operator<(const node &a) const {
    for (int i = 1; i <= K; i++) {
      if (maxn[i] >= a.minn[i]) return false;
    }
    return true;
  }
};
set<node> st;
vector<node> vec;
int main() {
  int n;
  cin >> n >> K;
  node now;
  for (int i = 1; i <= n; i++) {
    now.sz = 1;
    for (int j = 1; j <= K; j++) {
      scanf("%d", &now.maxn[j]);
      now.minn[j] = now.maxn[j];
    }
    auto it = st.lower_bound(now);
    if (it == st.end()) {
      st.insert(now);
    } else {
      vec.clear();
      while (it != st.end() && (now < *it) == false) {
        vec.push_back(*it);
        for (int i = 1; i <= K; i++) {
          now.maxn[i] = max(now.maxn[i], (*it).maxn[i]);
          now.minn[i] = min(now.minn[i], (*it).minn[i]);
        }
        now.sz += (*it).sz;
        it++;
      }
      for (node u : vec) st.erase(u);
      st.insert(now);
    }
    printf("%d\n", st.rbegin()->sz);
  }
}
