#include #include using namespace std; typedef long long ll; int main(){ int n, m; cin >> n >> m; int ans = -1; long double e = -1; for(int i = 0; i < m; i++){ int x[n]; for(int j = 0; j < n; j++) cin >> x[j]; auto calc = [&](int a, int b, int c) -> int{ if(b > c) swap(b, c); if(a > b) swap(a, b); if(b > c) swap(b, c); if((x[b]-x[a])*(x[b]-x[c]) > 0) return max({x[a], x[b], x[c]}); else return 0; }; ll sum = 0; for(int j = 0; j < n; j++){ for(int k = j+1; k < n; k++){ int tmps = 0; for(int l = 0; l < n; l++){ if(j == l || k == l) continue; tmps = max(tmps, calc(j, k, l)); } sum += tmps; } } long double score = (double)sum / m / (m-1); if(score > e){ e = score; ans = i; } } cout << ans << endl; return 0; }