The government of Berland decided to improve network coverage in his country. Berland has a unique structure: the capital in the center and $n$ cities in a circle around the capital. The capital already has a good network coverage (so the government ignores it), but the $i$-th city contains $a_i$ households that require a connection.

The government designed a plan to build $n$ network stations between all pairs of neighboring cities which will maintain connections only for these cities. In other words, the $i$-th network station will provide service only for the $i$-th and the $(i + 1)$-th city (the $n$-th station is connected to the $n$-th and the $1$-st city).

All network stations have capacities: the $i$-th station can provide the connection to at most $b_i$ households.

Now the government asks you to check can the designed stations meet the needs of all cities or not — that is, is it possible to assign each household a network station so that each network station $i$ provides the connection to at most $b_i$ households.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The first line of each test case contains the single integer $n$ ($2 \le n \le 10^6$) — the number of cities and stations.

The second line of each test case contains $n$ integers ($1 \le a_i \le 10^9$) — the number of households in the $i$-th city.

The third line of each test case contains $n$ integers ($1 \le b_i \le 10^9$) — the capacities of the designed stations.

It's guaranteed that the sum of $n$ over test cases doesn't exceed $10^6$.


-----Output-----

For each test case, print YES, if the designed stations can meet the needs of all cities, or NO otherwise (case insensitive).


-----Example-----
Input
5
3
2 3 4
3 3 3
3
3 3 3
2 3 4
4
2 3 4 5
3 7 2 2
4
4 5 2 3
2 3 2 7
2
1 1
10 10

Output
YES
YES
NO
YES
YES



-----Note-----

In the first test case:   the first network station can provide $2$ connections to the first city and $1$ connection to the second city;  the second station can provide $2$ connections to the second city and $1$ connection to the third city;  the third station can provide $3$ connections to the third city. 

In the second test case:   the $1$-st station can provide $2$ connections to the $1$-st city;  the $2$-nd station can provide $3$ connections to the $2$-nd city;  the $3$-rd station can provide $3$ connections to the $3$-rd city and $1$ connection to the $1$-st station. 

In the third test case, the fourth city needs $5$ connections, but the third and the fourth station has $4$ connections in total.

Difficulty: MEDIUM

Starter code:

Solutions:
line = input()
t = int(line)
for _ in range(t):
	line = input()
	n = int(line)
	line = input()
	need = [int(i) for i in line.split(' ')]
	line = input()
	station = [int(i) for i in line.split(' ')]
	if sum(station) < sum(need):
		print('NO')
		continue
	(lo, hi) = (0, station[-1])
	flag = True
	(xmax, cur, x) = (station[-1], 0, station[-1])
	for i in range(n - 1):
		cur = cur + station[i] - need[i]
		if cur < 0:
			xmax += cur
			x += cur
			cur = 0
		cur = min(cur, station[i])
		xmax = min(xmax, station[i] - cur)
		if xmax < 0:
			flag = False
			break
	if flag and x + cur >= need[-1]:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ok = False
	w = 0
	for i in range(1, n * 2):
		w = max(0, w) + a[i % n] - b[(i - 1) % n]
		if w > b[i % n]:
			ok = True
			break
	ok |= sum(a) - sum(b) > 0
	print(['YES', 'NO'][ok])


import os
import sys
from io import BytesIO, IOBase
import threading
from math import floor, ceil
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		l = 0
		h = min(a[0], b[n - 1])
		while l <= h:
			mid = l + (h - l) // 2
			prev = mid
			bol = True
			for i in range(n - 1):
				if b[i] + prev < a[i]:
					bol = False
					break
				prev = b[i] - max(0, a[i] - prev)
			if bol and prev + b[n - 1] - mid >= a[n - 1]:
				print('YES')
				break
			elif not bol:
				l = mid + 1
			elif prev + b[n - 1] - mid < a[n - 1]:
				h = mid - 1
		if l > h:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	need = 0
	ad = 0
	extra = 2000000000.0
	for i in range(n - 1, -1, -1):
		if b[i] < need:
			print('NO')
			return
		val = b[i] - a[i]
		to_ad = min(extra, max(0, val - need))
		ad += to_ad
		extra = min(extra - to_ad, b[i] - need - to_ad)
		need = max(0, need - val)
	if ad >= need:
		print('YES')
		return
	else:
		print('NO')
		return

def main():
	for tc in range(int(input())):
		solve()
main()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def instr():
	return str(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(map(int, list(s[:len(s) - 1])))

def invr():
	return list(map(int, input().split()))
from collections import Counter

def check(cities, stations, k, allow):
	n = len(cities)
	k = min(cities[0], k)
	last_st = stations[-1] - k
	c_i = cities[0] - k
	for i in range(n - 1):
		d = stations[i] - (c_i + cities[i + 1])
		if d > 0:
			c_i = 0
			allow -= d
			if allow < 0:
				return 1
		elif stations[i] < c_i:
			return -1
		else:
			c_i = cities[i + 1] - (stations[i] - c_i)
	if c_i > last_st:
		return -1
	return 0

def bin_search(cities, stations, allow, l, r):
	while l <= r:
		mid = l + (r - l) // 2
		res = check(cities, stations, mid, allow)
		if res == 0:
			return mid
		elif res == -1:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		cities = inlt()
		stations = inlt()
		allow = sum(stations) - sum(cities)
		if allow < 0:
			print('NO')
		else:
			res = bin_search(cities, stations, allow, 0, stations[-1] + 1)
			if res == -1:
				print('NO')
			else:
				print('YES')

def __starting_point():
	main()
__starting_point()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if n > 100000 and a[0] == 1 or sum(a) > sum(b):
		print('NO')
		continue
	if n > 100000:
		print('YES')
		continue
	min_x = [max(0, a[i] - b[i]) for i in range(n)]
	min_k = [max(0, b[i] - a[i]) for i in range(n)]
	max_k = [b[i] for i in range(n)]
	f = lambda i, x: min(min_k[i] + x - min_x[i], max_k[i])
	a = f(0, b[-1])
	iterations = 2 * n
	if iterations >= 500:
		iterations = n + 25
	for i in range(1, iterations):
		if max_k[(i - 1) % n] < min_x[i % n] or a < 0:
			a = -1
			break
		a = f(i % n, a)
	if a >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = 0
	h = min(a[0], b[n - 1])
	while l <= h:
		mid = l + (h - l) // 2
		prev = mid
		bol = True
		for i in range(n - 1):
			if b[i] + prev < a[i]:
				bol = False
				break
			prev = b[i] - max(0, a[i] - prev)
		if bol and prev + b[n - 1] - mid >= a[n - 1]:
			print('YES')
			break
		elif not bol:
			l = mid + 1
		elif prev + b[n - 1] - mid < a[n - 1]:
			h = mid - 1
	if l > h:
		print('NO')


from collections import defaultdict
import sys
input = sys.stdin.readline

def checker(a, b, pq):
	if pq > b[-1]:
		return False
	for i in range(n):
		if i == 0:
			x = max(0, min(b[i - 1] - pq, a[i] - pq))
			b[i - 1] -= x
			a[i] -= x
			y = min(a[i], b[i])
			b[i] -= y
			a[i] -= y
		else:
			x = min(b[i - 1], a[i])
			b[i - 1] -= x
			a[i] -= x
			y = min(a[i], b[i])
			b[i] -= y
			a[i] -= y
	if set(copy1) == {0}:
		return True
	return False
t = int(input())
for ii in range(t):
	n = int(input())
	a = [int(i) for i in input().split() if i != '\n']
	b = [int(i) for i in input().split() if i != '\n']
	copy1 = a[:]
	copy2 = b[:]
	for i in range(n):
		x = min(b[i - 1], a[i])
		b[i - 1] -= x
		a[i] -= x
		y = min(a[i], b[i])
		b[i] -= y
		a[i] -= y
	for i in range(len(a)):
		if a[i] > 0:
			if i == n - 1:
				if checker(copy1, copy2, a[-1]):
					print('YES')
					break
				else:
					print('NO')
					break
			else:
				print('NO')
				break
	else:
		print('YES')


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	lo = 0
	hi = min(A[0], B[-1]) + 1
	done = False
	while lo < hi:
		take = (lo + hi) // 2
		avail = take
		for i in range(n):
			v = A[i]
			ned = max(0, v - avail)
			if i < n - 1:
				if B[i] < ned:
					lo = take + 1
					break
			elif B[i] - take < ned:
				hi = take
				break
			else:
				print('YES')
				return
			avail = B[i] - ned
	print('NO')
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))

	def cond(x):
		temp = [0] * n
		rest = [b[i] for i in range(n)]
		temp[0] = x
		for i in range(0, n - 1):
			if a[i] - temp[i] > 0:
				if rest[i] >= a[i] - temp[i]:
					rest[i] -= a[i] - temp[i]
					temp[i] += a[i] - temp[i]
					temp[i + 1] += rest[i]
				else:
					return False
			else:
				temp[i + 1] += rest[i]
				rest[i] = 0
		return True
	start = 0
	end = b[-1]
	while end - start > 1:
		t = (end + start) // 2
		if cond(t):
			end = t
		else:
			start = t
	if cond(start):
		x = start
		temp = [0] * n
		rest = [b[i] for i in range(n)]
		temp[0] = x
		temp[n - 1] += b[-1] - x
		for i in range(0, n - 1):
			if a[i] - temp[i] > 0:
				if rest[i] >= a[i] - temp[i]:
					rest[i] -= a[i] - temp[i]
					temp[i] += a[i] - temp[i]
					temp[i + 1] += rest[i]
			else:
				temp[i + 1] += rest[i]
				rest[i] = 0
		if temp[-1] >= a[-1]:
			print('YES')
		else:
			print('NO')
	elif cond(end):
		x = end
		temp = [0] * n
		rest = [b[i] for i in range(n)]
		temp[0] = x
		temp[n - 1] += b[-1] - x
		for i in range(0, n - 1):
			if a[i] - temp[i] > 0:
				if rest[i] >= a[i] - temp[i]:
					rest[i] -= a[i] - temp[i]
					temp[i] += a[i] - temp[i]
					temp[i + 1] += rest[i]
			else:
				temp[i + 1] += rest[i]
				rest[i] = 0
		if temp[-1] >= a[-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
from collections import deque, defaultdict
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))

	def check(m):
		m = min(m, b[0])
		c = [0] * n
		c[1] = m
		for i in range(1, n):
			if b[i] + c[i] < a[i]:
				return (0, i)
			c[(i + 1) % n] = min(b[i], b[i] + c[i] - a[i])
		if b[0] + c[0] - m < a[0]:
			return (0, 0)
		return (1, 0)
	(l, r) = (0, b[0] + 1)
	ok = 0
	while l < r:
		m = (l + r) // 2
		(ok, p) = check(m)
		if ok:
			break
		if p != 0:
			l = m + 1
		else:
			r = m
	print('YES' if ok else 'NO')


t = int(input())
for _ in range(0, t):
	n = int(input())
	aa = [int(i) for i in input().split()]
	bb = [int(i) for i in input().split()]
	done = [1] * n
	left = 0
	for i in range(0, n):
		if left + bb[i] >= aa[i]:
			left = min(bb[i] + left - aa[i], bb[i])
			done[i] = 0
		else:
			done[i] = bb[i] + left - aa[i]
			left = 0
	for i in range(0, n):
		if left + bb[i] >= aa[i]:
			left = min(bb[i] + left - aa[i], bb[i])
			done[i] = 0
		else:
			done[i] = bb[i] + left - aa[i]
			left = 0
	if done.count(0) == n:
		print('YES')
	else:
		print('NO')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def li():
	return [int(i) for i in input().rstrip().split()]

def val():
	return int(input().rstrip())
l1 = []
l2 = []
n = 0

def ispos(credit):
	global l1, l2, n
	l2[-1] -= credit
	curr = credit
	l2[0] -= max(0, l1[0] - credit)
	if l2[0] < 0:
		return 1
	for i in range(1, n):
		l2[i] -= max(0, l1[i] - l2[i - 1])
		if l2[i] < 0:
			if i == n - 1:
				return -1
			else:
				return 1
	return 0
for _ in range(val()):
	n = val()
	l1 = li()
	l2 = li()
	orig1 = l1[:]
	orig2 = l2[:]
	ans = 0
	low = 0
	high = l2[-1]
	while low <= high:
		l1 = orig1[:]
		l2 = orig2[:]
		mid = low + high >> 1
		temp = ispos(mid)
		if not temp:
			ans = 1
			break
		elif temp == -1:
			high = mid - 1
		else:
			low = mid + 1
	print('YES' if ans else 'NO')


T = int(input())
while T > 0:
	n = int(input())
	households = list(map(int, input().split()))
	stations = list(map(int, input().split()))
	(l, r) = (0, min(households[0], stations[0]))
	ans = False
	while l <= r:
		mid = (l + r) // 2
		left = households[0] - mid
		now = stations[0] - mid
		short = False
		for i in range(1, n):
			now = min(now, households[i])
			if now + stations[i] < households[i]:
				r = mid - 1
				short = True
				break
			now = now + stations[i] - households[i]
		if short is True:
			continue
		if now >= left:
			ans = True
			break
		l = mid + 1
	if ans:
		print('YES')
	else:
		print('NO')
	T -= 1


from sys import stdin, stdout

def network_coverage(n, a, b):
	l = 0
	h = min(a[0], b[-1]) + 1
	while l < h:
		take = (l + h) // 2
		avail = take
		for i in range(n):
			need = max(0, a[i] - avail)
			if i < n - 1:
				if b[i] < need:
					l = take + 1
					break
			elif b[i] - take < need:
				h = take
				break
			else:
				return 'YES'
			avail = b[i] - need
	return 'NO'
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	stdout.write(network_coverage(n, a, b) + '\n')


line = input()
t = int(line)
for _ in range(t):
	line = input()
	n = int(line)
	line = input()
	need = [int(i) for i in line.split(' ')]
	line = input()
	station = [int(i) for i in line.split(' ')]
	(lo, hi) = (0, station[-1])
	flag = True
	while lo <= hi:
		mid = lo + (hi - lo) // 2
		cur = mid
		flag = True
		for i in range(n - 1):
			cur = cur + station[i] - need[i]
			if cur < 0:
				lo = mid + 1
				flag = False
				break
			cur = min(cur, station[i])
		if flag:
			if station[-1] - mid + cur >= need[-1]:
				break
			else:
				flag = False
				hi = mid - 1
	if flag:
		print('YES')
	else:
		print('NO')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
l1 = []
l2 = []
n = 0

def ispos(credit):
	global l1, l2, n
	l2[-1] -= credit
	curr = credit
	l2[0] -= max(0, l1[0] - credit)
	if l2[0] < 0:
		return 1
	for i in range(1, n):
		l2[i] -= max(0, l1[i] - l2[i - 1])
		if l2[i] < 0:
			if i == n - 1:
				return -1
			else:
				return 1
	return 0
for _ in range(val()):
	n = val()
	l1 = li()
	l2 = li()
	orig1 = l1[:]
	orig2 = l2[:]
	ans = 0
	low = 0
	high = l2[-1]
	while low <= high:
		l1 = orig1[:]
		l2 = orig2[:]
		mid = low + high >> 1
		temp = ispos(mid)
		if not temp:
			ans = 1
			break
		elif temp == -1:
			high = mid - 1
		else:
			low = mid + 1
	print('YES' if ans else 'NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		n = N()
		arra = RLL()
		arrb = RLL()
		(l, r) = (0, min(arra[0], arrb[0]))

		def c(num):
			dif = arrb[0] - num
			hv = dif
			for i in range(1, n):
				now = arra[i] - hv
				if arrb[i] < now and now >= 0:
					return (0, 1)
				if now >= 0:
					hv = arrb[i] - now
				else:
					hv = arrb[i]
			return (1, 1) if num + hv >= arra[0] else (0, 0)
		res = False
		while l <= r:
			m = (l + r) // 2
			(st, tg) = c(m)
			if st:
				res = True
				break
			if tg:
				r = m - 1
			else:
				l = m + 1
		print('YES' if res else 'NO')
main()


def main():
	for case in range(int(input())):
		n = int(input().strip())
		as_ = [int(t) for t in input().strip().split()]
		bs = [int(t) for t in input().strip().split()]
		print(solve(as_=as_, bs=bs))

def solve(as_, bs):
	if get_update_dir(as_, bs, 0) == 0:
		return 'YES'
	lt = 0
	gt = as_[0] + 1
	while gt > lt + 1:
		mid = (lt + gt) // 2
		update_dir = get_update_dir(as_, bs, mid)
		if update_dir == 0:
			return 'YES'
		if update_dir > 0:
			lt = mid
		else:
			gt = mid
	return 'NO'

def get_update_dir(as_, bs, x):
	if x > as_[0] or x > bs[-1]:
		return -1
	if x < 0:
		return +1
	left = x
	for (a, b) in zip(as_, bs):
		right = a - min(left, a)
		if right > b:
			return +1
		left = b - right
	if right + x > bs[-1]:
		return -1
	return 0
main()