#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) int main() { ios::sync_with_stdio(0); cin.tie(0); int n,m; cin >> n >> m; int ans; int a[800]; int mah[800], mat[800]; int mih[800], mit[800]; double maxv = - 1; rep(i,m) { rep(j, n)cin >> a[j]; mah[0] = mih[0] = a[0]; rep(j, n) { mah[j] = max(mah[j],a[j]); mih[j] = min(mih[j], a[j]); } mat[n-1] = mit[n-1] = a[n-1]; for (int j = n - 1; j >= 0; j--) { mat[j] = max(mat[j], a[j]); mit[j] = min(mit[j], a[j]); } double sum = 0; rep(j, n) { int ma, mi; ma = mi = a[j]; for (int k = j + 1; k < n; k++) { int x = 0; if (max(a[j], a[k]) < ma) { x = ma; } if (a[j] < a[k]) { if (mah[j] > a[j])x = max(x, max(a[k], mah[j])); else if (mat[k] < a[k])x = max(x, a[k]); } else if (a[j] > a[k]) { if (mat[k] > a[k])x = max(x, max(a[j], mat[k])); else if (mah[j] < a[j])x = max(x, a[j]); } sum += x; ma = max(ma, a[k]); mi = min(mi, a[k]); } } double v = sum / (double)(n*(n - 1) / 2); if (maxv < v) { maxv = v; ans = i; } } cout << ans << endl; return 0; }