class Solution:
def getMax(self, red, n, blue, m):
mx1 = 0
local = 0
for x in red:
local += x
mx1 = max(mx1, local)
mx2 = 0
local = 0
for x in blue:
local += x
mx2 = max(mx2, local)
print(mx1 + mx2)
return
def main():
t = int(input())
sol = Solution()
while t:
n = int(input())
red = list(map(int, input().strip().split()))
m = int(input())
blue = list(map(int, input().strip().split()))
sol.getMax(red, n, blue, m)
t -= 1
if __name__ == '__main__':
main()
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int INF=0x3f3f3f3f;
inline int read()
{
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0',c=getchar();}
return x*f;
}
const int N=110;
int a[N],b[N];
void solve()
{
int n=read();
for(int i=1;i<=n;i++)a[i]=read();
int m=read();
for(int i=1;i<=m;i++)b[i]=read();
int ans1=0,ans2=0,sum1=0,sum2=0;
for(int i=1;i<=n;i++)sum1+=a[i],ans1=max(ans1,sum1);
for(int i=1;i<=m;i++)sum2+=b[i],ans2=max(ans2,sum2);
cout<<ans1+ans2<<endl;
}
int main()
{
int T=read();
while(T--)solve();
return 0;
}
48A - Rock-paper-scissors | 294A - Shaass and Oskols |
1213A - Chips Moving | 490A - Team Olympiad |
233A - Perfect Permutation | 1360A - Minimal Square |
467A - George and Accommodation | 893C - Rumor |
227B - Effective Approach | 1534B - Histogram Ugliness |
1611B - Team Composition Programmers and Mathematicians | 110A - Nearly Lucky Number |
1220B - Multiplication Table | 1644A - Doors and Keys |
1644B - Anti-Fibonacci Permutation | 1610A - Anti Light's Cell Guessing |
349B - Color the Fence | 144A - Arrival of the General |
1106A - Lunar New Year and Cross Counting | 58A - Chat room |
230A - Dragons | 200B - Drinks |
13A - Numbers | 129A - Cookies |
1367B - Even Array | 136A - Presents |
1450A - Avoid Trygub | 327A - Flipping Game |
411A - Password Check | 1520C - Not Adjacent Matrix |