#include <cstdio>
#include <fstream>
#include <vector>
#include <algorithm>
#include <set>
#include <cassert>

using namespace std;

vector< vector<int> > s;
vector<size_t> ans, g;
vector< pair<int, size_t> > a;

const int MAX_VALUE = 1e9;
int main()
{
	ifstream cin("satellite.in");
	ofstream cout("satellite.out");
	size_t n, k;
	cin >> n >> k;
	assert(1 <= n && n <= 1000);
	assert(1 <= k && k <= 1000);
	s.resize(k);
	ans.resize(k);
	g.resize(k);
    a.clear();
	for (size_t i = 0; i < k; ++i)
	{
		s[i].resize(n);
		for (size_t j = 0; j < n; ++j)
		{
			cin >> s[i][j];
		}
        sort(s[i].begin(), s[i].end());
	}
	for (size_t i = 0; i < k; ++i)
	{
		for (size_t j = 0; j < k; ++j)
		{
			if (i == j) continue;
			for (size_t h = 0; h < n; ++h)
			{
				int l = -1, r = n, m = n / 2;
				while (l + 1 < r)
				{
					m = (l + r) / 2;
					if (s[i][h] > s[j][m]) l = m;
					else r = m;
				}
				ans[i] += r;
			}
		}
	}
	for (size_t i = 0; i < k - 1; ++i)
		cout << ans[i] << " ";
	cout << ans[k - 1]; 
}
