#include #include #include #include using namespace std; const int maxn=2005; int T,m,n,a[105][maxn],buf[maxn],*x,*y; struct ST { int i,j,flg; }; struct cmp { inline bool operator()(const ST &a,const ST &b) { return x[a.i]+y[a.j]>x[b.i]+y[b.j]; } }; inline void merge(int *a,int *b,int *c) { x=a; y=b; priority_queue,cmp> Q; Q.push((ST){0,0,0}); for(int k=0;k0) { scanf("%d%d",&m,&n); for(int i=0;i