1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <cstdio>

#define MAXN 100000
#define MAXK 5

long long int ABS (long long int a) {
	if (a < 0) return -a; return a;
}

long long int wyn[MAXK][MAXK];

long long int tab[MAXK][MAXN];

long long int licz(int a, int b, int n) {
	long long int wyn = 0;
	for (int i = 0; i < n; i++) {
		wyn += ABS(tab[a][i] - tab[b][i]);
	}
	return wyn;
}

int main() {
	int n, k;

	scanf("%d %d", &n, &k);

	for (int i = 0; i < k; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%lld", &tab[i][j]);
		}
	}

	for (int i = 0; i < k; i++) {
		for (int j = i + 1; j < k; j++) {
			wyn[i][j] = licz(i, j, n);
			wyn[j][i] = wyn[i][j];
		}
	}

	int w = -1;
	int min = -1;
	int max = 0;

	for (int i = 0; i < k; i++) {
		max = 0;

		for (int j = 0; j < k; j++) {
			if (wyn[i][j] > max) max = wyn[i][j];
		}

		if ((min == -1) || (max < min)) {
			min = max;
			w = i;
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%lld ", tab[w][i]);
	}
	printf("\n");


	return 0;
}