Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef owns a fast food shop that is currently located in a city called Chefland. He is planning to move his shop to a bigger city called Chefabad. There are $N$ consecutive days (numbered $1$ through $N$) such that the move can be done before day $1$, after day $N$ or between any two consecutive days. Moving the shop takes zero time. Chef wants to time the move in a way thay maximises his profit during these $N$ days.

For each $i$ ($1 ≤ i ≤ N$), we know that if Chef's shop is in Chefland on the $i$-th day, he earns $A_{i}$ coins, while if it is in Chefabad on this day, he earns $B_{i}$ coins. Find the maximum profit Chef can make if he optimally chooses the time when the shop should move. Note that once the shop has moved to Chefabad, it cannot return to Chefland.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.
The third line contains $N$ space-separated integers $B_{1}, B_{2}, \ldots, B_{N}$.

------  Output ------
For each test case, print a single line containing one integer ― the maximum profit.

------  Constraints ------
$1 ≤ T ≤ 1,000$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i}, B_{i} ≤ 10^{4}$ for each valid $i$
the sum of $N$ over all test cases does not exceed $10^{6}$

------  Subtasks ------
Subtask #1 (50 points):
$1 ≤ N ≤ 1,000$
the sum of $N$ over all test cases does not exceed $10,000$

Subtask #2 (50 points): original constraints

----- Sample Input 1 ------ 
3
3
2 3 2
10 3 4
4
7 5 3 4
2 3 1 3
2
10 1
1 10
----- Sample Output 1 ------ 
17
19
20
----- explanation 1 ------ 
Example case 1: The best time to move is before the first day.

Example case 2: The best time to move is after the last day.

Example case 3: The best time to move is after the first day.

Difficulty: MEDIUM
Tags: Range queries
Skill types: Range queries

Starter code:

Solutions:
for _ in range(int(input())):
	n = int(input())
	listland = list(map(int, input().split()))
	listbad = list(map(int, input().split()))
	sumland = sum(listland)
	sumbad = sum(listbad)
	l = []
	sweepland = 0
	sweepbad = sumbad
	for i in range(n):
		l.append(sweepland + sweepbad)
		sweepland += listland[i]
		sweepbad -= listbad[i]
		l.append(sweepland + sweepbad)
	print(max(l))


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	a = sum(lst)
	b = sum(lst1)
	max1 = max(a, b)
	(f, s, k, l) = (0, 0, 0, 0)
	for j in range(n):
		f += lst[j]
		s += lst1[j]
		l = b - s
		if max1 < l + f:
			max1 = l + f
	print(max1)


import sys
import math
import random
from collections import defaultdict
from queue import PriorityQueue
from itertools import permutations
from bisect import bisect_left, bisect_right
from math import ceil, floor, sqrt
from typing import List, Tuple
from functools import cmp_to_key
from collections import deque
from queue import Queue
from heapq import heapify, heappush, heappop
from random import randint

def max(a: int, b: int) -> int:
	return a if a > b else b

def min(a: int, b: int) -> int:
	return a if a < b else b

def sol():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(pre, suf) = ([0] * (n + 1), [0] * (n + 1))
	pre[0] = a[0]
	for i in range(1, n):
		pre[i] = pre[i - 1] + a[i]
	suf[n - 1] = b[n - 1]
	for i in range(n - 2, -1, -1):
		suf[i] = suf[i + 1] + b[i]
	ans = max(pre[n - 1], suf[0])
	for i in range(n - 1):
		ans = max(pre[i] + suf[i + 1], ans)
	print(ans)

def main():
	test = int(input())
	for i in range(test):
		sol()
main()


tc = int(input())

def profit_max(N, A, B):
	(A_profit, B_profit) = (sum(A), sum(B))
	result = max(A_profit, B_profit)
	(A_curr_sum, B_curr_sum) = (0, 0)
	for i in range(N):
		A_curr_sum += A[i]
		B_curr_sum += B[i]
		poss_sum = B_profit - B_curr_sum + A_curr_sum
		result = max(result, poss_sum)
	return result
for i in range(tc):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	print(profit_max(N, A, B))


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l = []
	s1 = 0
	s2act = 0
	for i in range(n):
		s2act += l2[i]
	l.append(s2act)
	for i in range(n):
		s1 += l1[i]
		s2act = s2act - l2[i]
		l.append(s1 + s2act)
	print(max(l))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	rst = [0] * n
	B = sum(b)
	A = sum(a)
	sm = B
	for i in range(n):
		sm += a[i]
		sm -= b[i]
		rst[i] = sm
	ans = max(rst)
	ans = max(max(A, B), ans)
	print(ans)


for i in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	s2 = sum(b)
	ans = []
	for i in range(n):
		ans.append(s + s2)
		s += a[i]
		s -= b[i]
	ans.append(sum(a))
	print(max(ans))


for _ in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	s1 = 0
	s2 = sum(arr2)
	ans = []
	for i in range(n):
		ans.append(s1 + s2)
		s1 += arr1[i]
		s2 -= arr2[i]
	ans.append(sum(arr1))
	ans.append(sum(arr2))
	print(max(ans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	g = sum(b)
	s = [g]
	for i in range(n):
		g = g + a[i] - b[i]
		s.append(g)
	print(max(s))


for _ in range(int(input())):
	n = int(input())
	a1 = list(map(int, input().split()))
	b1 = list(map(int, input().split()))
	earn_chefland = 0
	earn_chefabad = 0
	for i in range(n):
		earn_chefland += a1[i]
		earn_chefabad += b1[i]
		if earn_chefland > earn_chefabad:
			earn_chefabad = earn_chefland
	print(earn_chefabad)


def soln(n, arr, brr):
	b_sum = sum(brr)
	res = b_sum
	cur = b_sum
	for i in range(n):
		cur += arr[i]
		cur -= brr[i]
		res = max(res, cur)
	return res
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	print(soln(n, arr, brr))


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	sum1 = 0
	B = list(map(int, input().split()))
	sum2 = sum(B)
	res = sum2
	for i in range(N):
		sum1 += A[i]
		sum2 -= B[i]
		res = max(sum1 + sum2, res)
	print(res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split())) + [0]
	b = list(map(int, input().split())) + [0]
	marka = sum(a)
	markb = sum(b)
	m = 0
	track = 0
	for i in range(n + 1):
		m1 = max(track + marka, track + markb)
		marka -= a[i]
		markb -= b[i]
		track += a[i]
		if m1 > m:
			m = m1
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = sum(b)
	temp = res
	for i in range(n):
		temp += a[i]
		temp -= b[i]
		res = max(res, temp)
	print(res)


tests = int(input())
for i in range(tests):
	length = int(input())
	chefland = list(map(int, input().split()))
	chefabad = list(map(int, input().split()))
	ans = sum(chefabad)
	temp = ans
	for j in range(length):
		temp += chefland[j]
		temp -= chefabad[j]
		ans = max(ans, temp)
	print(ans)


from sys import stdin
ip = stdin.readline
for _ in range(int(ip())):
	n = int(ip())
	ar = list(map(int, ip().split()))
	br = list(map(int, ip().split()))
	sm = cSm = sum(br)
	for i in range(n):
		cSm = cSm - br[i] + ar[i]
		sm = max(sm, cSm)
	print(sm)


for _ in range(int(input())):
	n = int(input())
	chefland = list(map(int, input().split()))
	chefband = list(map(int, input().split()))
	for i in range(1, n):
		chefland[i] = chefland[i] + chefland[i - 1]
	for i in range(n - 2, -1, -1):
		chefband[i] += chefband[i + 1]
	m = 0
	for i in range(n - 1):
		if m < chefland[i] + chefband[i + 1]:
			m = chefland[i] + chefband[i + 1]
	if m < chefland[-1]:
		m = chefland[-1]
	if m < chefband[0]:
		m = chefband[0]
	print(m)


for _ in range(int(input())):
	n = int(input())
	Ai = list(map(int, input().split()))
	Bi = list(map(int, input().split()))
	sumeA = 0
	current = 0
	for i in range(n):
		sumeA += Ai[i]
		current += Bi[i]
		if sumeA > current:
			current = sumeA
	print(current)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	c = []
	while i < n:
		c.append(b[i] - a[i])
		i += 1
	s = 0
	for i in c:
		s = s + i
	z = [s]
	for i in c:
		z.append(s - i)
		s = s - i
	v = max(z)
	l = 0
	for i in a:
		l = l + i
	print(l + v)


testCases = int(input())
for testCase in range(testCases):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	preSum = []
	ps = 0
	sufSum = []
	ss = 0
	profit = []
	for i in range(n):
		ps += a[i]
		preSum.append(ps)
		ss += b[n - i - 1]
		sufSum.append(ss)
	sufSum.reverse()
	sufSum.append(0)
	preSum.insert(0, 0)
	print(max([i + j for (i, j) in zip(preSum, sufSum)]))


for _ in range(int(input())):
	n = int(input())
	Ai = list(map(int, input().split()))
	Bi = list(map(int, input().split()))
	s = 0
	(li1, li2) = ([], [])
	ans = []
	ans.append(sum(Bi))
	tot = sum(Bi)
	for i in range(n):
		s += Ai[i]
		li1.append(s)
	for j in range(n):
		tot -= Bi[j]
		li2.append(tot)
	for i in range(n):
		ans.append(li1[i] + li2[i])
	print(max(ans))


from math import gcd, sqrt, ceil, floor, log10, log2
from heapq import heapify, heappop, heappush, nsmallest, nlargest
from collections import Counter, deque, OrderedDict, defaultdict
from itertools import combinations, permutations, zip_longest
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
import sys
import time
import string
import operator
RECURSION_LIMIT = int(10000000.0)
INT_MAX = float('inf')
INT_MIN = float('-inf')
MOD = int(1000000000.0) + 7
NEWLINE = '\n'
SPACE = ' '
sys.setrecursionlimit(RECURSION_LIMIT)
inp = lambda fn: fn(input())
inp_vars = lambda fn, delim, convert_to=list: convert_to(map(fn, input().split(delim)))
enum = lambda itr: enumerate(itr)

def toposort(graph, n):
	degree = [0] * n
	for node in graph:
		for adj in graph[node]:
			degree[adj] += 1
	bfs_queue = [node for node in range(n) if not degree[node]]
	for node in bfs_queue:
		for adj in graph[node]:
			degree[adj] -= 1
			if not degree[adj]:
				bfs_queue.append(adj)
	return (bfs_queue, degree)

def dfs(graph, node, visited):
	visited.add(node)
	for adj in graph[node]:
		if adj in visited:
			continue
		dfs(graph, adj, visited)

def solve(*args, **kwargs):
	(n, arr1, arr2) = args
	(prefix1, prefix2) = ([arr1[0]], deque([arr2[-1]]))
	for ele in arr1[1:]:
		prefix1.append(prefix1[-1] + ele)
	for ele in arr2[:-1][::-1]:
		prefix2.appendleft(prefix2[0] + ele)
	res = max((prefix1[i] + prefix2[i + 1] for i in range(n - 1)))
	return max(res, prefix1[-1], prefix2[0])

def main(*args, **kwargs):
	for _ in range(int(input())):
		arg1 = inp(int)
		arg2 = inp_vars(int, SPACE)
		arg3 = inp_vars(int, SPACE)
		res = solve(*(arg1, arg2, arg3))
		if type(res) in {list, tuple, set}:
			print(*res, sep=' ')
		else:
			print(res)
main()


t = int(input())
for i in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	sum2 = 0
	sum1 = 0
	for l2 in list2:
		sum2 += l2
	for l1 in list1:
		sum1 += l1
	list3 = []
	list3.append(sum1)
	list3.append(sum2)
	l3 = 0
	while l3 < n:
		sum2 -= list2[l3]
		sum2 += list1[l3]
		l3 += 1
		list3.append(sum2)
	max = list3[0]
	for z in list3:
		if z > max:
			max = z
	print(max)


for _ in range(int(input())):
	n = int(input())
	cl = list(map(int, input().split()))
	cb = list(map(int, input().split()))
	for i in range(1, n):
		cl[i] += cl[i - 1]
	for j in range(n - 2, -1, -1):
		cb[j] += cb[j + 1]
	ans = 0
	for i in range(n - 1):
		ans = max(ans, cl[i] + cb[i + 1])
	ans = max(ans, cl[n - 1])
	ans = max(ans, cb[0])
	print(ans)


N = int(input())
for i in range(N):
	n = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	prev = 0
	A1 = []
	B1 = []
	for j in range(n):
		A1.append(prev + A[j])
		prev = A1[j]
	prev = 0
	for j in reversed(range(n)):
		B1.append(prev + B[j])
		prev = B1[n - j - 1]
	B1.reverse()
	Sum = []
	Sum.append(sum(A))
	Sum.append(sum(B))
	for k in range(len(A) - 1):
		Sum.append(A1[k] + B1[k + 1])
	print(max(Sum))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	for i in range(1, n):
		a[i] += a[i - 1]
	for i in range(n - 2, -1, -1):
		b[i] += b[i + 1]
	for i in range(n - 1):
		ans = max(ans, a[i] + b[i + 1])
	ans = max(ans, a[n - 1])
	ans = max(ans, b[0])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	sum1 = 0
	count = 0
	z = []
	w = []
	count = []
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	k = sum(y)
	l = sum(x)
	count.append(l)
	count.append(k)
	s = 0
	for j in x:
		s += j
		z.append(s)
	for j in y:
		k -= j
		w.append(k)
	for j in range(len(w)):
		count.append(w[j] + z[j])
	print(max(count))


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	sum1 = 0
	sum2 = sum(list2)
	list3 = []
	list3.append(sum2)
	for i in range(n):
		sum1 += list1[i]
		sum2 -= list2[i]
		list3.append(sum1 + sum2)
	print(max(list3))


T = int(input())
for test in range(T):
	N = int(input())
	s = input().split()
	A = []
	for i in range(N):
		A.append(int(s[i]))
	s = input().split()
	B = []
	profit = 0
	for i in range(N):
		B.append(int(s[i]))
		profit += B[i]
	maxprofit = profit
	for i in range(N):
		profit = profit - B[i] + A[i]
		if profit > maxprofit:
			maxprofit = profit
	print(maxprofit)


t = int(input())
for _ in range(t):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	for i in range(1, n):
		arr1[i] = arr1[i] + arr1[i - 1]
	for i in range(n - 2, -1, -1):
		arr2[i] = arr2[i] + arr2[i + 1]
	maxi = 0
	for i in range(n - 1):
		value = max(arr2[i + 1] + arr1[i], arr2[i])
		maxi = max(maxi, value)
	maxi = max(maxi, arr1[-1])
	print(maxi)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pa = [0 for i in range(n)]
	pb = [0 for i in range(n)]
	pa[0] = a[0]
	pb[n - 1] = b[n - 1]
	for i in range(1, n):
		pa[i] = pa[i - 1] + a[i]
		pb[n - i - 1] = pb[n - i] + b[n - i - 1]
	m = pa[n - 1]
	for i in range(n):
		if m < pa[i] - a[i] + pb[i]:
			m = pa[i] - a[i] + pb[i]
	print(m)


for _ in range(int(input())):
	n = int(input())
	ali = list(map(int, input().split()))
	bli = list(map(int, input().split()))
	sm = sum(bli)
	mx = sm
	for i in range(n):
		sm += ali[i] - bli[i]
		mx = max(mx, sm)
	print(mx)


def function(Input):
	for _ in range(Input):
		N = int(input())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		sum = 0
		for i in range(1, N):
			A[i] += A[i - 1]
		for i in range(N - 2, -1, -1):
			B[i] += B[i + 1]
		for i in range(0, N - 1):
			sum = max(sum, A[i] + B[i + 1])
		sum = max(sum, A[N - 1])
		sum = max(sum, B[0])
		print(sum)
	return ' '
Input = int(input())
a = function(Input)
print(a)


t = int(input())
for h in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	aSum = 0
	bSum = 0
	aArr = []
	bArr = [0] * n
	for k in range(n):
		aSum += A[k]
		aArr.append(aSum)
		bSum += B[n - 1 - k]
		bArr[n - 1 - k] = bSum
	arr = []
	ans1 = bArr[0]
	ans2 = aArr[n - 1]
	ans = 0
	for i in range(0, n - 1):
		ans = max(ans1, ans2, aArr[i] + bArr[i + 1], ans)
	print(ans)


import sys
input = sys.stdin.readline

def rii():
	return range(int(input().strip()))

def ii():
	return int(input().strip())

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())
from itertools import accumulate

def solve(*args):
	(n, chefland, chefabad) = args
	advantage = [b - l for (l, b) in zip(chefland, chefabad)]
	ans = [x for x in sorted(enumerate(list(accumulate(advantage[::-1]))[::-1]), key=lambda y: -y[1])][0]
	if ans[1] < 0:
		return sum(chefland)
	else:
		return sum(chefland[:ans[0]] + chefabad[ans[0]:])

def do_codechef():
	for t in rii():
		n = ii()
		a = lmii()
		b = lmii()
		print(solve(n, a, b))
do_codechef()
exit()


for _ in range(int(input())):
	n = int(input())
	arr = [0] + [int(a) for a in input().split()]
	brr = [0] + [int(a) for a in input().split()]
	for l in range(1, n + 1):
		arr[l] = arr[l - 1] + arr[l]
		brr[l] = brr[l - 1] + brr[l]
	val = -float('inf')
	for l in range(1, n + 1):
		c1 = arr[l - 1]
		c2 = brr[-1] - brr[l - 1]
		val = max(val, c1 + c2)
	val = max(val, arr[-1])
	print(val)


try:
	for _ in range(int(input())):
		n = int(input())
		A = list(map(int, input().split(' ')))
		B = list(map(int, input().split(' ')))
		prefix_A = [0 for _ in range(n)]
		suffix_B = [0 for _ in range(n)]
		prefix_A[0] = A[0]
		suffix_B[n - 1] = B[n - 1]
		for i in range(1, n):
			prefix_A[i] = prefix_A[i - 1] + A[i]
		for i in range(n - 2, -1, -1):
			suffix_B[i] = B[i] + suffix_B[i + 1]
		ans = 0
		for i in range(n - 1):
			s = prefix_A[i] + suffix_B[i + 1]
			if s > ans:
				ans = s
		if ans < prefix_A[n - 1]:
			ans = prefix_A[n - 1]
		if ans < suffix_B[0]:
			ans = suffix_B[0]
		print(ans)
except Exception:
	pass


try:
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		s = 0
		for i in range(1, n):
			a[i] += a[i - 1]
		for i in range(n - 2, -1, -1):
			b[i] += b[i + 1]
		for i in range(0, n - 1):
			s = max(s, a[i] + b[i + 1])
		s = max(s, a[n - 1])
		s = max(s, b[0])
		print(s)
except:
	pass


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(b)
	h = s
	for j in range(n):
		h += a[j] - b[j]
		if h > s:
			s = h
	print(s)


for w in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(b)
	k = s
	for i in range(n):
		k += a[i] - b[i]
		if k > s:
			s = k
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(k) for k in input().split()]
	s = sum(b)
	h = s
	for i in range(n):
		h += a[i] - b[i]
		if h > s:
			s = h
	print(s)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	z = sum(l2)
	p = z
	for i in range(n):
		z += l1[i] - l2[i]
		if z > p:
			p = z
	print(p)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	(res, sum1, sum2) = (0, 0, sum(l2))
	sum3 = sum2
	for i in range(n):
		sum1 += l1[i]
		sum2 -= l2[i]
		res = max(res, sum1 + sum2)
	print(max(res, sum3))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	m = sum(b)
	s = m
	for j in range(n):
		s = s + a[j] - b[j]
		if s > m:
			m = s
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	max_profit = sum(b)
	profit = max_profit
	for i in range(n):
		profit += a[i] - b[i]
		if profit > max_profit:
			max_profit = profit
	print(max_profit)


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = [0]
	l4 = [0] * (n + 1)
	for i in range(n):
		l3.append(l3[-1] + l1[i])
	ans = max(l3)
	for i in range(n - 1, -1, -1):
		l4[i] = l4[i + 1] + l2[i]
		ans = max(ans, l4[i] + l3[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	temp1 = [0]
	for j in lis1:
		x = temp1[-1] + j
		temp1.append(x)
	temp1.append(0)
	temp2 = [0]
	lis2.reverse()
	for j in lis2:
		x = temp2[-1] + j
		temp2.append(x)
	temp2.append(0)
	temp2.reverse()
	maxi = -1
	for j in range(n + 1):
		if temp1[j] + temp2[j + 1] > maxi:
			maxi = temp1[j] + temp2[j + 1]
	print(maxi)


T = int(input())
for i in range(T):
	n = int(input())
	a = []
	a.append(0)
	sum = 0
	for i in input().split():
		sum += int(i)
		a.append(sum)
	b = [int(x) for x in input().split()]
	b.append(0)
	for i in range(n - 1, -1, -1):
		b[i] += b[i + 1]
	ans = 0
	for i in range(0, n + 1):
		temp = a[i] + b[i]
		if temp > ans:
			ans = temp
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	e = 0
	g = 0
	d = sum(b)
	f = []
	f.append(d)
	for i in range(n):
		e += a[i]
		g += b[i]
		f.append(d - g + e)
	print(max(f))


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	(s1, s2, i, m) = (sum(l1), sum(l2), 0, 0)
	(m, a) = (s2, s2)
	for i in range(n):
		a += l1[i]
		a -= l2[i]
		if a > m:
			m = a
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	o_s = list(map(int, input().split()))
	n_s = list(map(int, input().split()))
	sum_n_s = sum(n_s)
	profit = sum_n_s
	for k in range(n):
		sum_n_s += o_s[k] - n_s[k]
		if sum_n_s > profit:
			profit = sum_n_s
	print(profit)


test_cases = int(input())
for i in range(test_cases):
	num_con_day = int(input())
	old_shop = list(map(int, input().split()))
	new_shop = list(map(int, input().split()))
	sum_new_shop = sum(new_shop)
	profit = sum_new_shop
	for k in range(num_con_day):
		sum_new_shop += old_shop[k] - new_shop[k]
		if sum_new_shop > profit:
			profit = sum_new_shop
	print(profit)


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	prefixa = [0] * n
	prefixb = [0] * n
	prefixa[0] = a[0]
	for i in range(1, n):
		prefixa[i] = prefixa[i - 1] + a[i]
	prefixb[n - 1] = b[n - 1]
	for i in range(n - 2, -1, -1):
		prefixb[i] = prefixb[i + 1] + b[i]
	maxi = 0
	for i in range(n + 1):
		if i == 0:
			temp = prefixb[0]
		elif i == n:
			temp = prefixa[n - 1]
		else:
			temp = prefixa[i - 1] + prefixb[i]
		if temp > maxi:
			maxi = temp
	print(maxi)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	bsum = 0
	for i in b:
		bsum += i
	c = bsum
	for i in range(n):
		c += a[i] - b[i]
		if c > bsum:
			bsum = c
	print(bsum)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = sum(b)
	c = d
	for i in range(n):
		c += a[i] - b[i]
		if c > d:
			d = c
	print(d)


for _ in range(int(input())):
	N = int(input())
	lstA = list(map(int, input().split()))
	lstB = list(map(int, input().split()))
	profit = sum(lstB)
	ans = profit
	for i in range(N):
		ans += lstA[i] - lstB[i]
		if ans > profit:
			profit = ans
	print(profit)


T = int(input())
ans = []
for _ in range(T):
	N = int(input())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	prefixa = []
	suffixb = []
	suma = 0
	for i in range(N):
		suma += A[i]
		prefixa.append(suma)
	sumb = 0
	for i in range(N - 1, -1, -1):
		sumb += B[i]
		suffixb.append(sumb)
	suffixb.reverse()
	maxi = -float('inf')
	for i in range(N - 1):
		if prefixa[i] + suffixb[i + 1] > maxi:
			maxi = prefixa[i] + suffixb[i + 1]
	ans.append(max(maxi, prefixa[-1], suffixb[0]))
for i in ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	x = 0
	y = sum(b)
	mg = y
	for i in range(n):
		x += a[i]
		y -= b[i]
		if x + y > mg:
			mg = x + y
	print(mg)


try:
	for i in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		max_profit = sum(b)
		profit = max_profit
		for i in range(n):
			profit += a[i] - b[i]
			if profit > max_profit:
				max_profit = profit
		print(max_profit)
except:
	pass


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = 0
	sum_l2 = sum(l2)
	ans = sum_l2
	for i in range(n):
		a += l1[i]
		b = a + sum_l2 - l2[i]
		sum_l2 = sum_l2 - l2[i]
		ans = max(b, ans)
	print(ans)


test = int(input())
for _ in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	day_f = sum(a)
	day_l = sum(b)
	pref = [0] * len(a)
	pref[0] = a[0]
	suf = [0] * len(b)
	suf[-1] = b[-1]
	for i in range(1, len(pref)):
		pref[i] = a[i] + pref[i - 1]
	for i in range(len(suf) - 2, -1, -1):
		suf[i] = b[i] + suf[i + 1]
	pref.pop(-1)
	suf.pop(0)
	mx = -1000000000.0
	for (x, y) in zip(pref, suf):
		mx = max(mx, x + y)
	print(max(day_f, day_l, mx))