#include <bits/stdc++.h>
using namespace std;
int n, k;
struct comp {
  int mx[11], mn[11], sz;
  void read() {
    for (int i = 0; i < k; i++) {
      scanf("%d", &mx[i]);
      mn[i] = mx[i];
    }
    sz = 1;
  }
};
comp c;
bool strictLess(const int *a, const int *b) {
  for (int i = 0; i < k; i++)
    if (a[i] > b[i]) return false;
  return true;
}
bool eq(int *a, const int *b) {
  for (int i = 0; i < k; i++)
    if (a[i] != b[i]) return false;
  return true;
}
void minn(const int *a, const int *b, int *c) {
  for (int i = 0; i < k; i++) c[i] = min(a[i], b[i]);
}
void maxx(const int *a, const int *b, int *c) {
  for (int i = 0; i < k; i++) c[i] = max(a[i], b[i]);
}
bool operator<(comp a, comp b) {
  if (!eq(a.mn, c.mn)) {
    return !(b < a);
  }
  if (strictLess(a.mn, b.mn)) return true;
  if (strictLess(b.mx, a.mn)) return false;
  return true;
}
void print(comp c) {
  cout << "sz : " << c.sz << endl;
  cout << "mx : ";
  for (int i = 0; i < k; i++) {
    cout << c.mx[i] << " ";
  }
  cout << endl;
  cout << "mn : ";
  for (int i = 0; i < k; i++) {
    cout << c.mn[i] << " ";
  }
  cout << endl;
}
int main() {
  set<comp> st;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    c.read();
    if (!st.empty()) {
      if (strictLess(c.mn, st.begin()->mn) ||
          strictLess((--st.end())->mx, c.mn)) {
      } else {
        set<comp>::iterator it = st.lower_bound(c);
        if (it == st.end()) cout << "OO" << endl;
        set<comp>::iterator it2 = it;
        while (it2 != st.end()) {
          if (strictLess(c.mx, it2->mn)) break;
          minn(c.mn, it2->mn, c.mn);
          maxx(c.mx, it2->mx, c.mx);
          c.sz += it2->sz;
          it2++;
        }
        st.erase(it, it2);
      }
    }
    st.insert(c);
    int ans = (--st.end())->sz;
    cout << ans << endl;
  }
}
