#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k;
struct node {
  int siz, mn[11], mx[11];
  bool operator<(const node& o) const {
    for (int i = (1), iend = (k); i <= iend; i++)
      if (mx[i] > o.mn[i]) return 0;
    return 1;
  }
};
set<node> s;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
int main() {
  n = read(), k = read();
  for (int i = (1), iend = (n); i <= iend; i++) {
    node t;
    t.siz = 1;
    for (int j = (1), jend = (k); j <= jend; j++) t.mn[j] = t.mx[j] = read();
    while (s.find(t) != s.end()) {
      auto it = s.find(t);
      for (int j = (1), jend = (k); j <= jend; j++)
        t.mn[j] = min(t.mn[j], (*it).mn[j]),
        t.mx[j] = max(t.mx[j], (*it).mx[j]);
      t.siz += (*it).siz;
      s.erase(it);
    }
    s.insert(t);
    auto it = s.rbegin();
    printf("%d\n", (*it).siz);
  }
  return 0;
}
