#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    int s[10] = {};
    vector<int> t(n), v[10];
    for (int j = 0; j < m; j++) {
        v[j] = vector<int>();
    }
    int x = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int r;
            cin >> r;
            if (r > s[j]) {
                for (auto& i1 : v[j]) {
                    t[i1] ^= 1 << j;
                    if (t[i1] == 0) x--;
                }
                v[j].clear();

                if (t[i] == 0) x++;
                s[j] = r;
                t[i] ^= 1 << j;
                v[j].push_back(i);

            } else if (r == s[j]) {
                if (t[i] == 0) x++;
                t[i] ^= 1 << j;
                v[j].push_back(i);
            }
        }
        cout << x << '\n';
    }

    return 0;
}