#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<stdio.h>
#include<queue>
#include<iomanip>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
bool cmp(int x,int y){
    return x>y?1:0;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,m;
        int r[105],b[105];
        cin>>n;
        int sum=0,ans1=0,ans2=0;
        for(int i=0;i<n;++i){
            cin>>r[i];
            sum+=r[i];
            ans1=max(ans1,sum);
        }
        cin>>m;
        sum=0;
        for(int i=0;i<m;++i){
            cin>>b[i];
            sum+=b[i];
            ans2=max(ans2,sum);
        }
        cout<<ans1+ans2<<endl;
    }
}
		   		 	   				 					  	  				