#include <bits/stdc++.h>

using namespace std;

int main(){
    int t;
    cin>>t;
    int n,m,r,b;
    while(t--){
        cin>>n;
        int prefr[n];
        int maxR = -1;
        for(int i=0; i<n; i++){
            cin>>r;
            if(i==0) prefr[i] = r;
            else prefr[i] = r+ prefr[i-1];
            if(prefr[i] > maxR) maxR = prefr[i];
        }
        cin>>m;
        int prefb[m];
        int maxB = -1;
        for(int i =0; i<m; i++) {
            cin>>b;
            if(i==0) prefb[i] = b;
            else prefb[i] = b+ prefb[i-1];
            if(prefb[i] > maxB) maxB = prefb[i];
        }
        if(maxR>=0 && maxB>=0){
            cout<<maxB+maxR<<endl;
        }else{
            cout<< max(max(maxR, maxB), 0)<<endl;
        }
    }
    return 0;
}
