#define I insert #define D erase #define S second #define V u,v,w,x #define U upper_bound ll@N,@K,@a[8N],H;set>A,C,E;rep(i,N)A.I({a[i],i}),C.I({a[2N+2i],2i}),C.I({a[2N+2i+1],2i+1}),E.I({a[6N+i],i});set>O;rep(K){auto x=E.begin(),u=A.U({x->first,N}),w=C.U({u->first,2N}),v=w++;O.I({a[N+u->S]+a[4N+v->S]+a[4N+w->S]+a[7N+x->S],u->S,v->S,w->S,x->S});A.D(u),C.D(v),C.D(w),E.D(x);}REP(n,1d7){if(n%4>2){auto&[h,V]=*O.begin();auto s=C.U({a[2N+v],2N}),e=C.end();if(s!=e)if(h<(H=h-a[4N+v]+a[4N+s->S]))O.D({h,V}),O.I({H,u,s->S,w,x}),C.D(s),C.I({a[2N+v],v});}else if(n%2){auto&[h,V]=*O.begin();auto t=C.U({a[2N+w],2N}),e=C.end();if(t!=e)if(h<(H=h-a[4N+w]+a[4N+t->S]))O.D({h,V}),O.I({H,u,v,t->S,x}),C.D(t),C.I({a[2N+w],w});}else if(n%4){auto&[h,V]=*O.rbegin();auto s=C.U({a[2N+v],2N}),e=C.end();if(s!=e)if(h>(H=h-a[4N+v]+a[4N+s->S]))O.D({h,V}),O.I({H,u,s->S,w,x}),C.D(s),C.I({a[2N+v],v});}else{auto&[h,V]=*O.rbegin();auto t=C.U({a[2N+w],2N}),e=C.end();if(t!=e)if(h>(H=h-a[4N+w]+a[4N+t->S]))O.D({h,V}),O.I({H,u,v,t->S,x}),C.D(t),C.I({a[2N+w],w});}}auto j=O.begin(),e=O.end();while(j!=e){auto&[h,V]=*j++;wt(u+1,v+1,w+1,x+1);}