#include <bits/stdc++.h>
using namespace std;
const int B = 11;
int n, m;
struct node {
  int mi[B], ma[B], sz;
} a;
inline int read() {
  int s = 0;
  char c;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    s = s * 10 + c - '0';
    c = getchar();
  }
  return s;
}
inline node operator+(node p, node q) {
  int i;
  for (i = 1; i <= m; i++) {
    p.mi[i] = min(p.mi[i], q.mi[i]);
    p.ma[i] = max(p.ma[i], q.ma[i]);
  }
  p.sz += q.sz;
  return p;
}
inline bool operator<(const node &p, const node &q) {
  int i;
  for (i = 1; i <= m; i++)
    if (p.ma[i] > q.mi[i]) return 1;
  return 0;
}
set<node> s;
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) a.mi[j] = a.ma[j] = read();
    a.sz = 1;
    for (set<node>::iterator it = s.upper_bound(a);
         it != s.end() && a < *it && *it < a;) {
      a = a + *it;
      s.erase(it++);
    }
    s.insert(a);
    printf("%d ", (*s.begin()).sz);
  }
}
