#include "bits/stdc++.h" #include #pragma warning(disable:4996) using namespace std; using ld = long double; template using Table = vector>; bool check(int l, int m, int r) { return (m > l&&m > r) || (m < l&&m < r); } int main() { int N, M; cin >> N >> M; vector>kitais(M); for (int i = 0; i < M; ++i) { long long nkitai = 0; vectores; for (int j = 0; j < N; ++j) { int e; cin >> e; es.push_back(e); } for (int j = 0; j < N; ++j) { for (int k = j+1; k < N; ++k) { if (j == k)continue; else { int nmoney = 0; for (int l = 0; l < j; ++l) { if (check(es[l], es[j], es[k]))nmoney = max(nmoney, es[l]); } for (int l = j+1; l < k; ++l) { if (check(es[j], es[l], es[k]))nmoney = max(nmoney, es[l]); } for (int l = k + 1; l < N; ++l) { if (check(es[j], es[k], es[l]))nmoney = max(nmoney, es[l]); } nkitai += nmoney; } } } kitais[i] = make_pair(nkitai, i); } cout << (*min_element(kitais.begin(), kitais.end())).second << endl; return 0; }