#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    for(int i=0;i<t;i++)
    {int max1=0;
        int n;
        cin>>n;
        int sum1=0;
        vector<int> v(n);
        for(int j=0;j<n;j++ )
        {
            cin>>v[j];
            sum1=sum1+v[j];
            if(sum1>max1){max1=sum1;}
        }
int max2=0;
        int m;
        cin>>m;
        int sum2=0;
        vector<int> s(m);
        for(int j=0;j<m;j++ )
        {
            cin>>s[j];
            sum2=sum2+s[j];
            if(sum2>max2){max2=sum2;}
        }


        cout<<(max(0,max1+max2))<<endl;


    }}