#include #include #include using namespace std; struct Node { int value1,value,sub; }node[10005],ex; int T,P,N; int i,sum; bool cmp1(struct Node p,struct Node q) { if(p.value!=q.value) return p.value>q.value; else return p.sub0) return 1; else return -1; } int main() { cin>>T; while(T--) { cin>>P>>N; sum=0; for(i=0;i0) { x=node[ln-1].value; if(lp/ln0) { int pre_ln=ln; for(i=0;i