MoEngage goes shopping with Chef. There are N ingredients placed on a line, numbered 1 to N from left to right.

At any point in time, MoEngage can choose the ingredient numbered x and do one of the following operations:
If the chosen ingredient is not the leftmost amongst the remaining ingredients, remove the left neighbor. This operation costs L_{x} coins.
If the chosen ingredient is not the rightmost amongst the remaining ingredients, remove the right neighbor. This operation costs R_{x} coins.

Note: MoEngage can perform at most one operation of one type on a particular ingredient. For example, you can't remove elements from the left of ingredient x two times. However, you can remove one ingredient each from the left and from the right of ingredient x.

MoEngage performs the operations until only one ingredient is left.  
Find the minimum number of coins he needs to pay so that only one ingredient is left.

------ Input Format ------ 

- The first line contains a positive integer T - the number of test cases. Then T test cases follow.
- The first line of each test case contains a single integer N - the number of ingredients.
- The second line of each test case contains N integers L_{1}, L_{2}, \ldots, L_{N} - the number of coins required to remove the ingredient from the left of an ingredient.
- The third line of each test case contains N integers R_{1}, R_{2}, \ldots, R_{N} - the number of coins required to remove the ingredient from the right of an ingredient.

------ Output Format ------ 

For each test case, output in a new line, one integer - the minimum number of coins MoEngage needs to pay so that only one ingredient is left.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$1 ≤ N ≤ 2 \cdot 10^{5}$
$1 ≤L_{i}, R_{i} ≤10^{9}$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$.

----- Sample Input 1 ------ 
3
1
3
4
4
2 1 3 2
4 2 4 3
7
3 10 5 2 8 3 9
8 6 11 5 9 13 7

----- Sample Output 1 ------ 
0
5
32

----- explanation 1 ------ 
- Test case 1: The number of ingredients is already $1$. Thus, MoEngage has to spend $0$ coins.
- Test case 2: Initially, the list of ingredients is $[1, 2, 3, 4]$. MoEngage can apply the operations in the following way:
- Apply the first operation on ingredient $4$. Coins required for this are $L_{4} = 2$. The updated list of ingredients is $[1, 2, 4]$.
- Apply the second operation on ingredient $2$. Coins required for this are $R_{2} = 2$. The updated list of ingredients is $[1, 2]$.
- Apply the first operation on ingredient $2$. Coins required for this are $L_{2} = 1$. The updated list of ingredients is $[2]$.

Thus, the total number of coins required is $2+2+1 = 5$. It can be shown that MoEngage cannot achieve a single ingredient in less than $5$ coins.

Source: codechef | Difficulty: HARD


Solutions:
T = int(input())
for _ in range(T):
	N = int(input())
	L = list(map(int, input().split()))
	R = list(map(int, input().split()))
	ans = 0
	for i in range(N - 1):
		ans += min(R[i], L[i + 1])
	print(ans)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans += min(r[i], l[i + 1])
	print(ans)


import math
n = int(input())
for i in range(n):
	a = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	p = 0
	for i in range(a - 1):
		p = p + min(l[i + 1], r[i])
	print(p)


T = int(input())
for i in range(T):
	N = int(input())
	L = list(map(int, input().split()))
	R = list(map(int, input().split()))
	if N == 1:
		print(0)
		continue
	B = [min(L[i + 1], R[i]) for i in range(0, N - 1)]
	print(sum(B))


def solving(*args):
	(n, l, r) = args
	if n == 1:
		return 0
	if n == 2:
		return min(l[-1], r[0])
	x = [min(l[i + 1], r[i]) for i in range(0, n - 1)]
	return sum(x)

def do_codechef():
	for t in range(int(input())):
		n = int(input())
		l = list(map(int, input().split(' ')))
		r = list(map(int, input().split(' ')))
		print(solving(n, l, r))
do_codechef()
exit()


for _ in range(int(input())):
	s = input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	tmp = 0
	for i in range(len(a) - 1):
		tmp += min(a[i + 1], b[i])
	print(tmp)


for _ in range(int(input())):
	n = int(input())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	min1 = 0
	for i in range(n - 1):
		min1 += min(lis2[i], lis1[i + 1])
	print(min1)


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


from sys import stdin, stdout
from collections import defaultdict
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	for j in range(n - 1):
		ans += min(b[j], a[j + 1])
	print(ans)


for t in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans += min(x[i + 1], y[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	ls1 = list(map(int, input().strip().split()))
	ls2 = list(map(int, input().strip().split()))
	x = 0
	for j in range(n - 1):
		x = x + min(ls1[j + 1], ls2[j])
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	f = list(map(int, input().split()))
	a = 0
	for i in range(n - 1):
		a += min(l[i + 1], f[i])
	print(a)


def solve(left, right):
	ans = 0
	for i in range(0, len(left) - 1):
		ans += min(right[i], left[i + 1])
	print(ans)
for t in range(int(input())):
	n = int(input())
	left = list(map(int, input().split()))
	right = list(map(int, input().split()))
	solve(left, right)


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


t = int(input())
for i in range(t):
	x = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	sum = 0
	for i in range(x - 1):
		sum += min(r[i], l[i + 1])
	print(sum)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	r = [int(x) for x in input().split()]
	ans = 0
	for i in range(n - 1):
		ans += min(l[i + 1], r[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans += min(arr1[i + 1], arr2[i])
	print(ans)


nt = int(input())
for g in range(0, nt):
	total = 0
	n = int(input())
	left = input()
	right = input()
	right = right.split(' ')
	left = left.split(' ')
	Y = []
	for i in range(0, len(left)):
		left[i] = int(left[i])
		right[i] = int(right[i])
	for i in range(0, n - 1):
		total = total + min(left[i + 1], right[i])
	print(total)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	print(sum([min(l[i + 1], r[i]) for i in range(n - 1)]))


from sys import stdin
input = stdin.readline

def get_string():
	return stdin.readline().strip()

def main():
	for _ in range(int(input())):
		n = int(input())
		left = list(map(int, input().split()))
		right = list(map(int, input().split()))
		s = 0
		for i in range(n - 1):
			s += min(right[i], left[i + 1])
		print(s)
main()


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		q = 0
		for i in range(1, n):
			q += min(l1[i], l2[i - 1])
		print(q)


t = int(input())
for _ in range(t):
	n = int(input())
	left = [int(x) for x in input().split()]
	right = [int(x) for x in input().split()]
	res = 0
	for i in range(n - 1):
		res += min(left[i + 1], right[i])
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		ans = 0
		for i in range(n - 1):
			ans += min(l[i + 1], r[i])
		print(ans)


allTestCase = int(input())
for testCase in range(allTestCase):
	N = int(input())
	L = list(map(int, input().split(' ')))
	R = list(map(int, input().split(' ')))
	ans = 0
	for i in range(N - 1):
		ans += min(R[i], L[i + 1])
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ans = 0
	if n == 1:
		print(0)
	else:
		for i in range(1, n):
			ans += min(l[i], p[i - 1])
		print(ans)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	val = 0
	for j in range(n - 1):
		val += min(r[j], l[j + 1])
	print(val)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	c = 0
	for i in range(0, n - 1):
		if r[i] >= l[i + 1]:
			c += l[i + 1]
			l[i + 1] = 10 ** 6
		else:
			c += r[i]
			r[i] = 10 ** 6
	print(c)


import sys
sys.setrecursionlimit(10 ** 8)

def min_coins(arr, l, r, start):
	if start >= len(arr) - 1:
		return 0
	else:
		return min(l[start + 1], r[start]) + min_coins(arr, l, r, start + 1)
test_cases = int(input())
while test_cases != 0:
	data = int(input())
	data2 = list(map(int, input().split()))
	data3 = list(map(int, input().split()))
	a = []
	for i in range(1, data + 1):
		a.append(i)
	print(min_coins(a, data2, data3, 0))
	test_cases -= 1


for T in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	count = 0
	for i in range(n - 1):
		count += min(l[i + 1], r[i])
	print(count)


noot = int(input())
for nool in range(noot):
	n = int(input())
	l = [int(x) for x in input().split()]
	r = [int(x) for x in input().split()]
	l = l[1:]
	r = r[0:n - 1]
	sum = 0
	for i in range(n - 1):
		sum += min(l[i], r[i])
	print(sum)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	r = [int(x) for x in input().split()]
	ans = [min(l[x + 1], r[x]) for x in range(n - 1)]
	print(sum(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().strip().split()))
	r = list(map(int, input().strip().split()))
	c = 0
	for i in range(n - 1):
		c += min(l[i + 1], r[i])
	print(c)


for _ in range(int(input())):
	a = input()
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	cnt = 0
	for i in range(len(l1) - 1):
		ans = min(l1[i + 1], l2[i])
		cnt += ans
	print(cnt)


t = int(input())
for i in range(t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans += min(lst2[i], lst1[i + 1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		s = 0
		for j in range(1, n):
			s += min(lsta[j], lstb[j - 1])
		print(s)


import collections
from math import ceil, gcd, sqrt, log
INF = float('inf')
mod = 1000000007

def solve():
	n = int(input())
	L = list(map(int, input().split()))
	R = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans += min(R[i], L[i + 1])
	print(ans)
t = int(input())
while t != 0:
	solve()
	t -= 1


from collections import *
import math, os, sys, heapq, bisect, random
from functools import lru_cache
from itertools import *

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def inpu():
	return int(inp())

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())
(M, M1) = (1000000007, 998244353)

def main():
	how_much_noob_I_am = 1
	how_much_noob_I_am = inpu()
	for case in range(how_much_noob_I_am):
		n = inpu()
		l = lis()
		r = lis()
		b = []
		for i in range(n - 1):
			b.append(min(l[i + 1], r[i]))
		print(sum(b))
main()


for i in range(int(input())):
	n = int(input())
	l = [int(k) for k in input().split()]
	r = [int(k) for k in input().split()]
	s = 0
	if n == 1:
		print(0)
	else:
		for k in range(1, n):
			if l[k] >= r[k - 1]:
				s += r[k - 1]
			else:
				s += l[k]
		print(s)


import math
import os
import random
import re
import sys
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if N == 1:
		print(0)
	else:
		ans = 0
		for i in range(1, N):
			ans += min(A[i], B[i - 1])
		print(ans)


for i in range(int(input())):
	myResult = 0
	num = int(input())
	myList = list(map(int, input().split()))
	tempList = list(map(int, input().split()))
	for i in range(num - 1):
		myResult += min(tempList[i], myList[i + 1])
	print(myResult)


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


from math import *
from collections import *
import os
from io import BytesIO, IOBase
import sys
from bisect import *
from heapq import *
MOD = 1000000007

def subinp():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('op1.txt', 'w')

def subinp_1():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('op2.txt', 'w')

def binpow(a, b, m):
	a %= m
	x = 1
	while b > 0:
		if b & 1:
			x = x * a % m
		a = a * a % m
		b >>= 1
	return x

def binser(arr, l, r, x):
	while l < r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return mid

def lcm(a, b):
	return a * b // gcd(a, b)

def sod(n):
	l = list(str(n))
	s = 0
	for i in l:
		s += int(i)
	return s

def prime_factors(num):
	l = []
	if num % 2:
		l.append(2)
	while num % 2 == 0:
		num = num / 2
	for i in range(3, int(sqrt(num)) + 1, 2):
		if not num % i:
			l.append(i)
		while num % i == 0:
			num = num / i
	if num > 2:
		l.append(num)
	return l

def factmod(n, p):
	f = defaultdict(int)
	f[0] = 1
	for i in range(1, n + 1):
		f[i] = f[i - 1] * i % MOD
	return f

def largestPower(n, p):
	x = 0
	while n:
		n //= p
		x += n
	return x

def modFact(n, p):
	if n >= p:
		return 0
	res = 1
	isPrime = [1] * (n + 1)
	i = 2
	while i * i <= n:
		if isPrime[i]:
			for j in range(2 * i, n, i):
				isPrime[j] = 0
		i += 1
	for i in range(2, n):
		if isPrime[i]:
			k = largestPower(n, i)
			res = res * binpow(i, k, p) % p
	return res

def drec(x, y):
	if y == x + 1:
		return 'R'
	if y == x - 1:
		return 'L'
	if x < y:
		return 'D'
	return 'U'

def cellhash(x, y):
	return (x - 1) * m + y

def bins(l, x, n):
	i = bisect_left(l, x)
	if i < n:
		return i
	if i:
		return i - 1
	else:
		return n

def cond(l):
	for i in range(len(l) - 1):
		if l[i] == str(int(l[i + 1]) - 1):
			return False
	return True

def isvowel(s):
	if s in list('aeiou'):
		return 1
	return 0

def countOdd(L, R):
	N = (R - L) // 2
	if R % 2 != 0 or L % 2 != 0:
		N += 1
	return N

def tst(A, B, C):
	return (A | B) & (B | C) & (C | A)

def palcheck(n, s):
	(i, j) = (0, n - 1)
	while i <= j:
		if s[i] == s[j]:
			return False
		i += 1
		j -= 1
	return True

def sakurajima(n):
	if n < 9:
		n = 10
	l = [0]
	for i in range(1, n + 1):
		if i % 2:
			l.append(i)
		else:
			l.append(2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if l[i] == i:
			for j in range(i * i, n + 1, i):
				if l[j] == j:
					l[j] = i
	return l

def getfact(x):
	ret = []
	d = defaultdict(int)
	while x != 1:
		ret.append(spf[x] ** (d[spf[x]] + 1))
		d[spf[x]] += 1
		x = x // spf[x]
	return ret

def prchck(n):
	l = [1] * (n + 1)
	l[1] = 0
	for i in range(2, n + 1):
		for j in range(2, int(sqrt(n)) + 1):
			if j % i == 0:
				l[j] = 1
	return l

def ispal(s, n):
	for i in range(n // 2):
		if s[i] != s[n - i - 1]:
			return False
	return True

def bfs(src, dest, ajl, vis):
	q = deque([src])
	vis[src] = True
	while q:
		i = q.popleft()
		if i == dest:
			return True
		for j in ajl[i]:
			if not vis[j]:
				vis[j] = True
				q.append(j)
	return False

def sieve(n):
	if n < 9:
		n = 10
	l = [1] * (n + 1)
	for i in range(2, int(n ** 0.5) + 1):
		if l[i]:
			for j in range(i ** 2, n + 1, i):
				if j % i == 0:
					l[j] = 0
	l[1] = 0
	return l

class DisjSet:

	def __init__(self, n):
		self.size = [1] * n
		self.parent = [i for i in range(n)]

	def find(self, x):
		if self.parent[x] != x:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, x, y):
		xset = self.find(x)
		yset = self.find(y)
		if xset == yset:
			return
		if self.size[xset] < self.size[yset]:
			self.parent[xset] = yset
			self.size[yset] += self.size[xset]
		else:
			self.parent[yset] = xset
			self.size[xset] += self.size[yset]

def dfs(i, ajl, vis, l, x):
	vis[i] = True
	l[i] = x
	for j in ajl[i]:
		if not vis[j]:
			dfs(j, ajl, vis, l, x)

def checkpo3(N):
	while N > 0:
		if N % 3 == 2:
			return False
		N //= 3
	return True

def sumofdig(n):
	ans = 0
	s = str(n)
	for i in s:
		ans += int(i)
	return ans

def convert(set):
	return [*set]
inp = lambda : int(input())
strin = lambda : input().strip()
strl = lambda : list(input().strip())
strlst = lambda : list(map(str, input().split()))
mult = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
lstin = lambda : list(map(int, input().strip().split()))
flush = lambda : stdout.flush()
stdpr = lambda x: stdout.write(str(x))

def peng(src, ajl, vis):
	q = deque([src])
	vis[src] = True
	ans = 0
	while q:
		i = q.pop()
		sm = 0
		for j in ajl[i]:
			if not vis[j]:
				print(i, j)
				vis[j] = True
				q.append(j)
				sm += 1
		print(i, ajl[i], sm)
		if i != 1:
			ans += sm / max(len(ajl[i]) - 1, 1)
		else:
			ans += sm / max(len(ajl[i]), 1)
	return ans

def panda(n, l, r):
	if n < 2:
		return 0
	if n == 2:
		return min(l[1], r[0])
	i = 0
	ans = 0
	for i in range(n - 1):
		if l[i + 1] < r[i]:
			ans += l[i + 1]
		else:
			ans += r[i]
		i += 1
	return ans
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
t = int(input())
for _ in range(t):
	n = inp()
	l = lstin()
	r = lstin()
	ans = panda(n, l, r)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	if n == 1:
		print(0)
	lward = [0 for i in range(n)]
	rward = [0 for i in range(n)]
	arr = []
	for j in range(1, len(l)):
		arr.append([l[j], 'L', j - 1])
	for j in range(len(r) - 1):
		arr.append([r[j], 'R', j + 1])
	arr.sort()
	ans = 0
	count = 0
	for j in range(len(arr)):
		if arr[j][1] == 'L' and lward[arr[j][2] + 1] != 1:
			y = arr[j][2]
			while y >= 0 and lward[y] == 1:
				rward[y] = 1
				y -= 1
			if y != -1:
				count += 1
				ans += arr[j][0]
				rward[y] = 1
		elif arr[j][1] == 'R' and rward[arr[j][2] - 1] != 1:
			y = arr[j][2]
			while y <= n - 1 and rward[y] == 1:
				lward[y] = 1
				y += 1
			if y != n:
				count += 1
				ans += arr[j][0]
				lward[y] = 1
		if count == n - 1:
			print(ans)
			break


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dp1 = [0] * n
	dp2 = [0] * n
	dp2[n - 1] = 0
	for i in range(n - 2, -1, -1):
		dp2[i] = min(b[i], a[i + 1]) + dp2[i + 1]
	dp1[0] = 0
	i = 1
	while i < n:
		dp1[i] = min(b[i - 1], a[i]) + dp1[i - 1]
		i += 1
	ans = min(dp2[0], dp1[n - 1])
	i = 1
	while i + 1 < n != None:
		ans = min(ans, dp1[i - 1] + dp2[i + 1] + a[i] + b[i])
		i += 1
	print(ans, end='')
	print('\n', end='')


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))[:n]
	right = list(map(int, input().split()))[:n]
	c = 0
	i = 1
	while i < n:
		a = l[i]
		b = right[i - 1]
		c += min(a, b)
		i += 1
	print(c)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	R = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		win = [0, 1]
		ans = 0
		while True:
			a = R[win[0]]
			b = L[win[1]]
			ans += min(a, b)
			win = [win[0] + 1, win[1] + 1]
			if win[1] == n:
				break
		print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
for u in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		q = 0
		for i in range(1, n):
			q += min(a[i], b[i - 1])
		print(q)


for i in range(int(input())):
	x = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	jj = 0
	if len(l1) == 1:
		print(0)
	else:
		for i in range(1, x):
			jj += min(l1[i], l2[i - 1])
		print(jj)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		a = 0
		for i in range(1, n):
			a += min(l[i], r[i - 1])
		print(a)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	r = [int(x) for x in input().split()]
	if n == 1:
		print(0)
	else:
		ret = 0
		for i in range(1, n):
			ret += min(l[i], r[i - 1])
		print(ret)