#include <bits/stdc++.h>
using namespace std;

const int N = 102;
int t, n, m, r[N], b[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	for(int ti = 1; ti <= t; ++ti) {
		cin >> n;
		for(int i = 1; i <= n; ++i) {
			cin >> r[i];
			r[i] += r[i - 1];
		}
		cin >> m;
		for(int i = 1; i <= m; ++i) {
			cin >> b[i];
			b[i] += b[i - 1];
		}
		int fp = 0;
		for(int i = 0; i <= n; ++i) {
			for(int j = 0; j <= m; ++j) {
				fp = max(fp, r[i] + b[j]);
			}
		}
		cout << fp << "\n";
	}
	return 0;
}
