#include using namespace std; int main() { int n, m; cin >> n >> m; vector> r(n, vector(m)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> r[i][j]; } } map ushi[10]; for (int j = 0; j < m; ++j) { int maxr = 0; for (int i = 0; i < n; ++i) { if (r[i][j] >= maxr) { ushi[j][r[i][j]] = i; maxr = r[i][j]; } } ushi[j][maxr] = n; } vector ans(n + 1); for (int i = 0; i < n; ++i) { int idx = -1; for (int j = 0; j < m; ++j) { if (ushi[j].count(r[i][j]) && i <= ushi[j][r[i][j]]) { idx = max(idx, ushi[j][r[i][j]]); } } if (~idx) { ans[i]++; ans[idx + 1]--; } } for (int i = 0; i < n; ++i) { cout << ans[i] << endl; ans[i + 1] += ans[i]; } }