#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,n) for(int i=(a);i<(n);++i)
#define BREP(i,a,n) for(int i=(a);i>(n);--i)
#define TRAV(i, v) for(auto &i: v)
#define fi first
#define se second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INDEX(arr,ind)	(upper_bound(ALL(arr),ind)-arr.begin())
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define pow10(n) stoll("1"+string(n,'0'))
#define EPS 1e-9
// #define LOCAL 1

typedef long long ll; 
typedef long double ld;
typedef pair<int, int> ii; 
typedef pair<ll, ll> pll; 
typedef vector < int > vi;
typedef vector < ll > vll;
typedef vector<ii> vii; 
typedef map<int, int> mii;

const long long INF = 1LL << 60;



void solve(){
	int n, m;
	cin >> n;
	vi r(n);
	REP(i,0,n) cin >> r[i];

	cin >> m;
	vi b(m);
	REP(j,0,m) cin >> b[j];

	int mxr = max(0, r[0]), mxb=max(0, b[0]);
	REP(i,1,n){
		r[i]=r[i]+r[i-1];
		mxr=max(r[i], mxr);
	}
	REP(i,1,m){
		b[i]=b[i]+b[i-1];
		mxb=max(b[i], mxb);
	}
	cout << mxr+mxb << endl;	
}

int main(){
	
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);		
	#endif

	int T;
	cin >> T;
	for (int tc = 1; tc <= T; ++tc)
	{
		// cout << "Case #" << tc << ": ";
		solve();
	}
	return 0;
}