#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main() {
    int t, n, m, x, mx, ot1, ot2;
    string s;
    cin >> t;
    while (t--){
        mx = 0;
        ot1 = 0;
        ot2 = 0;
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> x;
            mx += x;
            if (mx > ot1){
                ot1 = mx;
            }
        }
        mx = 0;
        cin >> m;
        for (int i = 0; i < m; i++){
            cin >> x;
            mx += x;
            if (mx > ot2){
                ot2 = mx;
            }
        }
        cout << ot1 + ot2 << endl;
    }
}
