/*
      Ashraful Islam Paran
      28-December-2020
      20:26:23
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define show(x, y) cout << x << "         " << y << "\n"
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= x; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
const int mod = 1e9 + 7;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

void print(vi &v)
{
    f(v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    

    w(t)
    {
        int n;
        cin >> n;
        vi a(n);
        f(n)
        {
            cin >> a[i];
        }
        int m;
        cin >> m;
        vi b(m);
        f(m)
        {
            cin >> b[i];
        }
        vi x;
        int i = 0, cnt = 0, j = 0;
        int x1=0,x2=0,s1=0,s2=0;
        f(n)
        {
            s1+=a[i];
            x1=max(x1,s1);
        }
        f(m)
        {
            s2+=b[i];
            x2=max(x2,s2);
        }
        cout<<x1+x2<<endl;
    }

    cerr << "Time : " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}