#include<bits/stdc++.h>
#define M416 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define ull unsigned long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;

// author-->slayer_07

int32_t main()
{
    M416


    int t;
    cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n;
        vector<int> a(n+1);
        for ( int i=1 ; i<=n ; i++ )
        {
            cin>>a[i];
            a[i] += a[i-1];
        }
        cin>>m;
        vector<int> b(m+1);
        for ( int i=1 ; i<=m ; i++ )
        {
            cin>>b[i];
            b[i] += b[i-1];
        }

        int ans=0;
        for ( int i=0 ; i<=n ; i++ )
        {
            for ( int j=0 ; j<=m ; j++ )
            {
                ans = max(ans,a[i]+b[j]);
            }
        }
        cout<<ans<<"\n";

    }    


    //cout <<endl<<endl<< 1.0 * clock() / CLOCKS_PER_SEC <<endl;
    return 0;
}