#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 100005
int t,n,m;
int a[MAX],b[MAX],suma[MAX],sumb[MAX];
int main()
{
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		int maxx1=0,maxx2=0;
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
			if(i==0){
				suma[i]=a[i];
				maxx1=max(maxx1,suma[i]);
			}
			if(i>0){
				suma[i]=suma[i-1]+a[i];
				maxx1=max(maxx1,suma[i]);
			}
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%d",&b[i]);
			if(i==0){
				sumb[i]=b[i];
				maxx2=max(maxx2,sumb[i]);
			}
			else {
				sumb[i]=sumb[i-1]+b[i];
				maxx2=max(maxx2,sumb[i]);
			}
		}
		maxx1=max(0,maxx1);
		maxx2=max(0,maxx2);
		printf("%d\n",max(maxx1+maxx2,0));
	}
    return 0;
}
