#include <iostream>
#include <cassert>
#include <fstream>
#include <set>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main()
{
	ifstream in("satellite.in");
	ofstream out("satellite.out");
	size_t n, k;
	in >> n >> k;
	assert (1 <= n && n <= 700);
	assert (1 <= k && k <= 700);

	set<int> was;
	int a[k][n];
	for (size_t i = 0; i < k; i++) {
		for (size_t j = 0; j < n; j++) {
			in >> a[i][j];
			//assert (was.count(a[i][j]) == 0);
			//was.insert(a[i][j]);
		}
	}
	int d[k][k];
	for (size_t i = 0; i < k; i++)
		fill(d[i], d[i] + k, 0);
	for (size_t r1 = 0; r1 < k; r1++)
		for (size_t r2 = r1 + 1; r2 < k; r2++)
			for (size_t i = 0; i < n; i++)
				for (size_t j = 0; j < n; j++)
					if (a[r1][i] > a[r2][j])
						d[r1][r2]++;
					else
						d[r2][r1]++;
	for (size_t j = 0; j < k; j++)
	{
		int sum = 0;
		for (size_t i = 0; i < k; i++)
			sum += d[j][i];
		out << sum << (j == k - 1 ? "" : " ");
	}
	out << endl;
}
