#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M; int A[1010]; ll ma=0; int best=0; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M; FOR(i,M) { FOR(x,N) cin>>A[x]; ll tot=0; FOR(x,N) { set L,M,R; FOR(y,x) L.insert(A[y]); for(y=x+1;yA[x]) sc=max(A[y],*L.rbegin()); if(A[x]>A[y] && *L.begin()max(A[x],A[y])) sc=max(sc,*M.rbegin()); if(*M.begin()A[y] && *R.rbegin()>A[y]) sc=max(sc,max(A[x],*R.rbegin())); if(A[x]ma) ma=tot,best=i; } cout<