#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000007 int isKadomatsu(int a, int b, int c){ if((ac)||(a>b&&ab)||(c>a&&c v){ int d[1005][1005]; clr(d,0); rep(i,0,v.sz){ rep(j,i+1,v.sz){ rep(k,j+1,v.sz){ if(isKadomatsu(v[i],v[j],v[k])==1){ d[min(v[i],v[j])][max(v[i],v[j])] = max(d[min(v[i],v[j])][max(v[i],v[j])],max(v[i],max(v[j],v[k]))); d[min(v[i],v[k])][max(v[i],v[k])] = max(d[min(v[i],v[k])][max(v[i],v[k])],max(v[i],max(v[j],v[k]))); d[min(v[j],v[k])][max(v[j],v[k])] = max(d[min(v[j],v[k])][max(v[j],v[k])],max(v[i],max(v[j],v[k]))); } } } } int ret = 0; rep(i,1,v.sz+1){ rep(j,i+1,v.sz+1){ ret += d[i][j]; } } return ret; } int main(){ int n,m; cin>>n>>m; long long mx = 0; int index = 0; rep(i,0,m){ vector v; rep(j,0,n){ int a; cin>>a; v.pb(a); } long long b = f(v); if(b>mx){ mx = b; index = i; } } cout << index << endl; return 0; } // 想定誤解法