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

#define ll                   long long int
#define pb                   push_back
#define mod                  1000000007
#define M2                   998244353
#define inf                  1e18
#define ff                   first
#define ss                   second
#define w(x)                 ll x=1; cin>>x; while(x--)
#define mid_of(l,r)          (l+(r-l)/2)
#define pii                  pair<ll,ll>
#define vi                   vector<ll>
#define mii                  unordered_map<ll, ll>
#define sii                  unordered_set<ll>
#define ps(x,y)              fixed<<setprecision(y)<<x
#define loop(i,a,b)          for(ll i = (a); i <= (b); i++)
#define looprev(i,b,a)       for(ll i = (b); i >= (a); i--)
#define mem(dp, val)         memset(dp, val, sizeof(dp))
#define setbits(x)           __builtin_popcountll(x)
#define pq_max               priority_queue<ll>
#define pq_min               priority_queue<ll,vector<ll>,greater<ll>>
#define all(v)               v.begin(), v.end()
#define logarr(arr,a,b)      for(ll i=(a);i<=(b);i++) cout<<(arr[i])<<" "; cout<<"\n";
#define fast_io              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll n, m;
ll total = 0, ans = 0;
vector<ll> red;
vector<ll> blue;

ll dp[105][105];

ll findAns(ll i, ll j, ll prev) {
    if(i == n and j == m) {
        return 0;
    }

    if(dp[i][j] != -1)
        return dp[i][j];

    ll temp1, temp2, temp;

    if(i == n) {
        ll max_sum = 0, sum = 0;
        while(j < m) {
            sum += blue[j];
            j++;
            max_sum = max(max_sum, sum);
        }

        ans = max(ans, prev + max_sum);

        dp[i][j] = max_sum;
        return max_sum;
    }

    if(j == m) {
        ll max_sum = 0, sum = 0;
        while(i < n) {
            sum += red[i];
            i++;
            max_sum = max(max_sum, sum);
        }

        ans = max(ans, prev + max_sum);
        dp[i][j] = max_sum;
        return max_sum;
    }


    temp1 = findAns(i + 1, j, prev + red[i]);
    temp2 = findAns(i, j + 1, prev + blue[j]);

    ans = max(ans, prev + red[i]);
    ans = max(ans, prev + red[i] + temp1);

    ans = max(ans, prev + blue[j]);
    ans = max(ans, prev + blue[j] + temp2);

    temp = 0;
    temp = max({temp, red[i], blue[j]});
    temp = max({temp, red[i] + temp1, blue[j] + temp2});

    dp[i][j] = temp;
    return temp;
}

void solve() {
    memset(dp, -1, sizeof(dp));
    // ll n;
    cin >> n;

    total = 0;
    ans = 0;
    // vector<ll> red;
    red.resize(n);
    for(ll i = 0; i < n; i++) {
        cin >> red[i];
        total += red[i];
    }

    // ll m;
    cin >> m;
    // vector<ll> blue;
    blue.resize(m);
    for(ll i = 0; i < m; i++) {
        cin >> blue[i];
        total += blue[i];
    }

    ans = max(ans, total);

    ans = max(ans, findAns(0, 0, 0));

    cout << ans << "\n";
}

int32_t main() {
    fast_io;

    ll ntc = 1;
    cin >> ntc;

    for(ll t = 1; t <= ntc; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}