#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ int N,M; cin >> N >> M; vector A(N),B(M),C(N),D(M); for(auto &a : A) cin >> a; for(auto &b : B) cin >> b; for(auto &a : C) cin >> a,a--; for(auto &b : D) cin >> b,b--; long long answer = -1; auto f = [&]() -> void { vector T = B; for(int i=1; i long long { long long ret = T.at(r); if(l) ret -= T.at(l-1); return ret; }; vector>> P(N+M); vector>> Q(N+M); long long sum = 0; for(int i=0; i