# include "bits/stdc++.h" using namespace std; using LL = long long; using ULL = unsigned long long; const double PI = acos(-1); templateconstexpr T INF() { return ::std::numeric_limits::max(); } templateconstexpr T HINF() { return INF() / 2; } template T_char TL(T_char cX) { return tolower(cX); }; template T_char TU(T_char cX) { return toupper(cX); }; typedef pair pii; const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 }; const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; } int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; } int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; } LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); }; LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; }; # define ALL(qpqpq) (qpqpq).begin(),(qpqpq).end() # define UNIQUE(wpwpw) sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end()) # define LOWER(epepe) transform(ALL((epepe)),(epepe).begin(),TL) # define UPPER(rprpr) transform(ALL((rprpr)),(rprpr).begin(),TU) # define FOR(i,tptpt,ypypy) for(LL i=(tptpt);i<(ypypy);i++) # define REP(i,upupu) FOR(i,0,upupu) # define INIT std::ios::sync_with_stdio(false);std::cin.tie(0) int n, m; vector e; vector> v; struct SegmentTree { private: int n; vector node; public: SegmentTree(vector v) { int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, -HINF()); for(int i=0; i=0; i--) node[i] = max(node[2*i+1], node[2*i+2]); } //[a,b)の最大値を求める int getmax(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return -HINF(); if(a <= l && r <= b) return node[k]; int vl = getmax(a, b, 2*k+1, l, (l+r)/2); int vr = getmax(a, b, 2*k+2, (l+r)/2, r); return max(vl, vr); } }; struct SegmentTree2 { private: int n; vector node; public: SegmentTree2(vector v) { int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, -HINF()); for(int i=0; i=0; i--) node[i] = min(node[2*i+1], node[2*i+2]); } //[a,b)の最小値を求める int getmin(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return -HINF(); if(a <= l && r <= b) return node[k]; int vl = getmin(a, b, 2*k+1, l, (l+r)/2); int vr = getmin(a, b, 2*k+2, (l+r)/2, r); return min(vl, vr); } }; bool kado(int a, int b, int c){ if(a == b || a == c || b == c)return false; int mid = a + b + c - max({a, b, c}) - min({a, b, c}); if(mid == a || mid == c)return true; return false; } void solve(int idx){ double sum = 0.0; e.resize(n); REP(i, n)cin >> e[i]; SegmentTree seg(e); SegmentTree2 seg2(e); double cnt = 0; REP(i, n)for(int j = i + 2;j < n;j++){ int maxl = 0; int xmax = seg.getmax(0, i); int xmin = seg2.getmin(0, i); int ymax = seg.getmax(i + 1, j); int ymin = seg2.getmin(i + 1, j); int zmax = seg.getmax(j + 1, n); int zmin = seg2.getmin(j + 1, n); if(e[i] < e[j]){ maxl = max({(xmax > e[i] && i != 0 ? max(xmax, e[j]) : 0), max((ymax > e[j] ? max(ymax, e[j]) : 0), (ymin < e[i] ? max(ymin, e[j]) : 0)), (zmin < e[j] && j != n - 1 ? max(zmin, e[j]) : 0)}); }else{ maxl = max({(xmin < e[i] && i != 0 ? max(xmin, e[i]) : 0), max((ymax > e[i] ? max(ymax, e[i]) : 0), (ymin < e[j] ? max(ymin, e[i]) : 0)), (zmax < e[j] && j != n - 1 ? max(zmax, e[i]) : 0)}); } sum += maxl; cnt += 1.0; } v.emplace_back(make_pair(sum/cnt, -idx)); } int main(){ INIT; cin >> n >> m; REP(i, m){ solve(i); } sort(ALL(v)); reverse(ALL(v)); cout << -v[0].second << endl; }