#include <bits/stdc++.h>
#define endl '\n'
#define LL long long
#define LD long double
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
int const MAXN = 2e6 + 9;
int main(){
    ios_base::sync_with_stdio (0),cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int mx1 = 0, mx2 = 0;
        int sum = 0;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            sum += x;
            mx1 = max(mx1, sum);
        }
        cin >> n;
        sum = 0;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            sum += x;
            mx2 = max(mx2, sum);
        }
        cout << mx2 + mx1 << endl;
    }
}