#include <bits/stdc++.h>
using namespace std;

#define ar array
#define ll long long int

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;



void solve() {
    ll n,m;
    cin>>n;
    ll r[n],i,j,f=0;
    for(i=0;i<n;i++) cin>>r[i];
    cin>>m;
    ll b[m];
    for(i=0;i<m;i++) cin>>b[i];
    
    ll s,mr=INT_MIN,mb=INT_MIN;
    
    s=0;
    for(i=0;i<n;i++)
    {
        s+=r[i];
        if(s>mr) mr=s;
    }
    s=0;
    for(i=0;i<m;i++)
    {
        s+=b[i];
        if(s>mb) mb=s;
    }
    
    f=max({f, mr, mb, mr+mb});
    
    
    cout<<f<<endl;
    return;
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int tc; cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}
