#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define lp(i,n) for(int i=0;i<n;i++)
#define lp2(i,a,n) for(int i=a;i<n;i++)
#define lli long long int
#define ulli unsigned long long int
#define mod (int)(1e9+7)
#define see(ar)    for(int i=0;i<(sizeof(ar)/sizeof(ar[0]));i++)    cout<<ar[i]<<" "; cout<<endl;
#define seev(v) for( auto it:v) cout<<it<<" "; cout<<endl;
#define vi vector<int>
#define vll vector<lli>
#define pii pair<int,int>
#define pll pair<lli,lli>
#define all(v) v.begin(),v.end()
#define all_rev(v) v.rbegin(),v.rend()
#define lb(v,i) lower_bound(v.begin(),v.end(),i)-v.begin()
#define ub(v,i) upper_bound(v.begin(),v.end(),i)-v.begin()
#define bsr(v,i) binary_search(v.begin(),v.end(),i)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define umap unordered_map
using namespace std;
lli solve(vi a)
{
    lli cr=0,mxsf=LONG_MIN;
    for(int i=0;i<a.size();i++)
    {
        cr+=a[i];
        // if(cr<0)
        //     cr=0;
        if(cr>mxsf)
            mxsf=cr;
    }
    return max(0LL,mxsf);
}
//lli power(lli a, lli b){ lli r=power(a,b/2); r=(r*r)%mod; if(b&1) r=(r*a)%mod; return r;}
int main()
{
    fast;
    lli t,n,k,v,p,l,m,r,a,b,c;
    string s;
    char ch;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vi a(n,0);
        lp(i,n) cin>>a[i];
        lli sm=solve(a);

        cin>>m;
        vi b(m,0);
        lp(i,m) cin>>b[i];
        sm+=solve(b);
        cout<<sm<<endl;


    }
    
    return 0;
}