Kristina has two arrays $a$ and $b$, each containing $n$ non-negative integers. She can perform the following operation on array $a$ any number of times:

apply a decrement to each non-zero element of the array, that is, replace the value of each element $a_i$ such that $a_i > 0$ with the value $a_i - 1$ ($1 \le i \le n$). If $a_i$ was $0$, its value does not change.

Determine whether Kristina can get an array $b$ from an array $a$ in some number of operations (probably zero). In other words, can she make $a_i = b_i$ after some number of operations for each $1 \le i \le n$?

For example, let $n = 4$, $a = [3, 5, 4, 1]$ and $b = [1, 3, 2, 0]$. In this case, she can apply the operation twice:

after the first application of the operation she gets $a = [2, 4, 3, 0]$;

after the second use of the operation she gets $a = [1, 3, 2, 0]$.

Thus, in two operations, she can get an array $b$ from an array $a$.


-----Input-----

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

The descriptions of the test cases follow.

The first line of each test case contains a single integer $n$ ($1 \le n \le 5 \cdot 10^4$).

The second line of each test case contains exactly $n$ non-negative integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$).

The third line of each test case contains exactly $n$ non-negative integers $b_1, b_2, \dots, b_n$ ($0 \le b_i \le 10^9$).

It is guaranteed that the sum of $n$ values over all test cases in the test does not exceed $2 \cdot 10^5$.


-----Output-----

For each test case, output on a separate line:

YES, if by doing some number of operations it is possible to get an array $b$ from an array $a$;

NO otherwise.

You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).


-----Examples-----

Input
6
4
3 5 4 1
1 3 2 0
3
1 2 1
0 1 0
4
5 3 7 2
1 1 1 1
5
1 2 3 4 5
1 2 3 4 6
1
8
0
1
4
6
Output
YES
YES
NO
NO
YES
NO


-----Note-----

The first test case is analyzed in the statement.

In the second test case, it is enough to apply the operation to array $a$ once.

In the third test case, it is impossible to get array $b$ from array $a$.

Difficulty: EASY

Solutions:
def check(a, b):
	difference = False
	dval = 0
	mindifference = 0
	for (x, y) in zip(a, b):
		if y > x:
			return False
		if y < 1:
			if difference:
				if x - y > dval:
					return False
			elif x - y > mindifference:
				mindifference = x - y
		else:
			if x - y < mindifference:
				return False
			if difference:
				if x - y != dval:
					return False
			else:
				difference = True
				dval = x - y
	return True
for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	b = map(int, input().split())
	if check(a, b):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(c, d) = (0, 0)
	for i in range(n):
		if b[i] != 0:
			c = a[i] - b[i]
			d = 1
			break
	if c < 0:
		print('NO')
	elif d == 0:
		print('YES')
	else:
		for i in range(n):
			if a[i] - b[i] == c or (b[i] == 0 and a[i] - b[i] <= c):
				continue
			else:
				print('NO')
				break
		else:
			print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	isd = False
	dmx = 0
	d = 0
	for i in range(n):
		if b[i] == 0:
			if a[i] > dmx:
				dmx = a[i]
		elif not isd:
			isd = True
			d = a[i] - b[i]
		elif d != a[i] - b[i]:
			print('NO')
			break
		if isd and dmx > d:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = map(int, input().split())
	b = map(int, input().split())
	f = False
	d = -1
	for (i, j) in zip(a, b):
		if i < j:
			print('NO')
			break
		if j == 0:
			if f and i - j > d:
				print('NO')
				break
			elif not f:
				d = max(d, i - j)
		elif f and i - j != d:
			print('NO')
			break
		elif not f:
			if i - j >= d:
				d = i - j
				f = True
			else:
				print('NO')
				break
	else:
		print('YES')


def main():
	for _ in range(int(input())):
		if problem():
			print('YES')
		else:
			print('NO')

def problem():
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	if any((a < b for (a, b) in zip(arr, brr))):
		return False
	if all((b == 0 for b in brr)):
		return True
	(min_i, min_b) = (None, float('inf'))
	for (i, b) in enumerate(brr):
		if 0 < b < min_b:
			(min_i, min_b) = (i, b)
	diff = arr[min_i] - brr[min_i]
	return all((max(0, a - diff) == b for (a, b) in zip(arr, brr)))
import sys
input = sys.stdin.readline
exit(main())


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	for i in range(n):
		if brr[i] != 0:
			t = arr[i] - brr[i]
			break
	else:
		print('YES')
		continue
	for i in range(n):
		if brr[i] == 0:
			if arr[i] - brr[i] > t:
				print('NO')
				break
			continue
		if brr[i] - arr[i] > 0:
			print('NO')
			break
		if t != arr[i] - brr[i]:
			print('NO')
			break
	else:
		print('YES')


n = int(input())
for i in range(n):
	l = input()
	a_s = input()
	b_s = input()
	(a, b) = (a_s.split(' '), b_s.split(' '))
	target = -1
	for (i, v) in enumerate(b):
		if int(a[i]) < int(v):
			target = -2
			break
		if int(v) != 0:
			target = int(a[i]) - int(v)
			break
	if target == -1:
		print('YES')
		continue
	elif target == -2:
		print('NO')
		continue
	for (i, v) in enumerate(b):
		if max(int(a[i]) - target, 0) != int(v):
			print('NO')
			break
	else:
		print('YES')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 0
	while k < n and b[k] == 0:
		k += 1
	if k == n:
		print('YES')
		return
	t = a[k] - b[k]
	if t < 0:
		print('NO')
		return
	for i in range(n):
		if not (a[i] - b[i] == t or (a[i] - b[i] < t and b[i] == 0)):
			print('NO')
			return
	print('YES')
for i in range(int(input())):
	solve()


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = -1
	for i in range(n):
		if b[i] != 0:
			x = i
			break
	else:
		print('YES')
		continue
	const = a[x] - b[x]
	if const < 0:
		print('NO')
		continue
	fail = 0
	for i in range(n):
		if b[i] == 0:
			if a[i] - b[i] > const:
				fail = 1
				break
		elif a[i] - b[i] != const:
			fail = 1
			break
	if fail:
		print('NO')
	else:
		print('YES')


def solve(a, b):
	first = -1
	for i in range(len(b)):
		if b[i] != 0:
			first = i
			break
	if first == -1:
		return 'YES'
	d = a[i] - b[i]
	if d < 0:
		return 'NO'
	for i in range(len(a)):
		n = max(0, a[i] - d)
		if n != b[i]:
			return 'NO'
	return 'YES'

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		print(solve(a, b))
main()


t = int(input(''))
for i in range(t):
	n = int(input(''))
	a = input('').split(' ')
	b = input('').split(' ')
	m = 0
	c = 1
	d = -1
	for j in range(n):
		if int(a[j]) < int(b[j]):
			c = 0
			break
		if int(b[j]) == 0:
			if m < int(a[j]):
				m = int(a[j])
			continue
		if d == -1:
			d = int(a[j]) - int(b[j])
		elif d != int(a[j]) - int(b[j]):
			c = 0
			break
	if d != -1 and m > d:
		c = 0
	if c == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	n -= 1
	input()
	arr1 = map(int, input().split())
	arr2 = map(int, input().split())
	f = True
	f2 = True
	k = 0
	for (i, j) in zip(arr1, arr2):
		t = i - j
		if t < 0:
			print('NO')
			f2 = False
			break
		if f:
			if j > 0:
				if k > t:
					print('NO')
					f2 = False
					break
				k = t
				f = False
			elif j == 0:
				k = max(k, t)
		elif t > k:
			print('NO')
			f2 = False
			break
		elif t < k:
			if j == 0:
				continue
			else:
				print('NO')
				f2 = False
				break
	if f2:
		print('YES')


for j in range(0, int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	ans = 'YES'
	if l2.count(0) == n:
		ans = 'YES'
	else:
		x = 0
		while l2[x] == 0:
			x = x + 1
		d = l1[x] - l2[x]
		if d < 0:
			ans = 'NO'
		else:
			for i in range(0, n):
				if l1[i] - l2[i] < 0:
					ans = 'NO'
					break
				elif l1[i] - l2[i] != d:
					if l1[i] - l2[i] < d and l2[i] == 0:
						ans = 'YES'
					else:
						ans = 'NO'
						break
	print(ans)


def solve(n):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	max_zero = 0
	nonzero_diff = None
	for i in range(n):
		if b[i] == 0:
			max_zero = max(max_zero, a[i] - b[i])
			if nonzero_diff is not None:
				if max_zero > nonzero_diff:
					return 'NO'
		elif b[i] > a[i]:
			return 'NO'
		else:
			if nonzero_diff is None:
				nonzero_diff = a[i] - b[i]
				if nonzero_diff < max_zero:
					return 'NO'
				continue
			if nonzero_diff != a[i] - b[i]:
				return 'NO'
	return 'YES'
for i in range(int(input())):
	print(solve(int(input())))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	opM = None
	for i in range(n):
		if b[i] != 0:
			opM = a[i] - b[i]
			break
	if opM == None:
		print('YES')
	elif opM < 0:
		print('NO')
	else:
		flag = True
		for i in range(n):
			if a[i] < b[i]:
				flag = False
				break
			op = a[i] - b[i]
			if op != opM:
				if b[i] == 0 and op < opM:
					continue
				else:
					flag = False
					break
		if flag == False:
			print('NO')
		else:
			print('YES')


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos_delta = -1
	neg_delta = 0
	key = True
	for i in range(n):
		if b[i] == 0:
			neg_delta = max(neg_delta, a[i])
		elif b[i] > a[i]:
			key = False
			break
		elif pos_delta == -1:
			pos_delta = a[i] - b[i]
		elif pos_delta != a[i] - b[i]:
			key = False
			break
	if key and neg_delta > pos_delta and (pos_delta > -1):
		key = False
	if key:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if sum(l2) == 0:
		print('YES')
		continue
	for j in range(n):
		if l2[j] == 0:
			continue
		else:
			k = l1[j] - l2[j]
			break
	if k < 0:
		print('NO')
		continue
	for j in range(n):
		if l2[j] == 0:
			if l1[j] > k:
				print('NO')
				break
			elif j == n - 1:
				print('YES')
				break
		elif l1[j] - l2[j] == k:
			if j == n - 1:
				print('YES')
			else:
				continue
		else:
			print('NO')
			break


t = int(input())
for i in range(t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	q = True
	if sum(lst2) == 0:
		print('YES')
	else:
		for i in range(n):
			if lst2[i] != 0:
				q = lst1[i] - lst2[i]
				break
		if q < 0:
			print('NO')
		else:
			r = True
			for i in range(n):
				if lst2[i] != 0 and lst1[i] - lst2[i] != q:
					print('NO')
					r = False
					break
				if lst2[i] == 0 and lst1[i] > q:
					print('NO')
					r = False
					break
			if r:
				print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	B = set(b)
	B.discard(0)
	if not B:
		print('YES')
		continue
	else:
		for (i, x) in enumerate(b):
			if x != 0:
				idx = i
				break
		d = a[idx] - b[idx]
		if d < 0:
			print('NO')
			continue
		res = True
		for (i, x) in enumerate(a):
			if not (x - b[i] == d or (b[i] == 0 and x - b[i] < d)):
				res = False
				break
		if res:
			print('YES')
		else:
			print('NO')


def solve(a, b):
	i = 0
	while i < len(b) and b[i] == 0:
		i += 1
	if i == len(b):
		return 'YES'
	diff = a[i] - b[i]
	if diff < 0:
		return 'NO'
	for i in range(0, len(a)):
		if a[i] - b[i] != diff:
			if b[i] != 0:
				return 'NO'
			elif a[i] - b[i] > diff:
				return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	n = input()
	a = input().split(' ')
	b = input().split(' ')
	a = [int(ar) for ar in a]
	b = [int(ar) for ar in b]
	c = solve(a, b)
	print(c)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q = 10 ** 9 + 1
	otv = 1
	maxb = 0
	for i in range(n):
		if b[i] == 0:
			if maxb < a[i]:
				maxb = a[i]
		elif q == 10 ** 9 + 1:
			q = a[i] - b[i]
		elif a[i] - b[i] != q:
			otv = -1
			break
	if otv == 1 and maxb <= q:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		if b[i] != 0:
			diff = a[i] - b[i]
			break
	else:
		print('YES')
		return
	if diff < 0:
		print('NO')
		return
	for i in range(n):
		if b[i] != 0 and a[i] - b[i] != diff:
			print('NO')
			return
		if b[i] == 0 and a[i] > diff:
			print('NO')
			return
	print('YES')
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = ma = t2 = 0
	t = 1
	for i in range(n):
		if b[i] == 0:
			if ma < a[i]:
				ma = a[i]
		elif t == 1:
			k = a[i] - b[i]
			t -= 1
		elif a[i] - b[i] != k:
			print('NO')
			t2 = 1
			break
	if t == 1:
		print('YES')
	elif t2 == 0 and ma <= k:
		print('YES')
	elif t2 == 0:
		print('NO')


t = int(input())
for z in range(t):
	flag = False
	check = True
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(n):
		if b[i] != 0:
			check = False
			diff = a[i] - b[i]
			break
	if check:
		diff = a[0] - b[0]
	if diff < 0:
		flag = True
	elif b == n * [0]:
		flag = False
	else:
		for i in range(0, n):
			if b[i] == 0:
				if diff >= a[i] - b[i]:
					continue
				else:
					flag = True
					break
			elif a[i] - b[i] != diff:
				flag = True
				break
			else:
				continue
	if flag:
		print('NO')
	else:
		print('YES')


p = print
r = range

def f(first_array, second_array):
	times = float('inf')
	for (x, y) in zip(first_array, second_array):
		if x < y:
			return 'NO'
		if y != 0:
			times = x - y
			break
	for (x, y) in zip(first_array, second_array):
		if y == 0 and x > times:
			return 'NO'
		if y != 0 and x - y != times:
			return 'NO'
	return 'YES'
number_of_test_cases = int(input())
for _var in r(number_of_test_cases):
	m = int(input())
	temp_array1 = list(map(int, input().split(' ')))
	temp_array2 = list(map(int, input().split(' ')))
	p(f(temp_array1, temp_array2))


def methodX():
	n = int(input())
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	integers = []
	min = 0
	for i in range(n):
		if second[i] == 0:
			if first[i] > min:
				min = first[i]
		else:
			if first[i] < second[i]:
				return 'NO'
			integers.append(first[i] - second[i])
	for i in range(1, len(integers)):
		if integers[i - 1] != integers[i]:
			return 'NO'
		if integers[i - 1] < min:
			return 'NO'
	if len(integers) != 0:
		if integers[0] < min:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	print(methodX())


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	non_z = None
	for i in range(n):
		if b[i]:
			non_z = i
			break
	if non_z is None:
		print('YES')
		continue
	dec = a[i] - b[i]
	if dec < 0:
		print('NO')
		continue
	poss = True
	for i in range(n):
		if max(a[i] - dec, 0) != b[i]:
			poss = False
			break
	if poss:
		print('YES')
	else:
		print('NO')


def fun(a, b):
	mn = 0
	c = 1000000001
	for i in range(n):
		if a[i] < b[i]:
			return 'NO'
		if b[i] == 0:
			mn = max(mn, a[i])
		elif c == 1000000001:
			c = a[i] - b[i]
		elif c != a[i] - b[i]:
			return 'NO'
	if c >= mn:
		return 'YES'
	else:
		return 'NO'
t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(fun(a, b))
	t -= 1


def f():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ind = 0
	while b[ind] == 0:
		ind += 1
		if ind == n:
			return True
	const = a[ind] - b[ind]
	if const < 0:
		return False
	for i in range(n):
		t = a[i] - b[i]
		if b[i] == 0 and (t > const or t < 0) or (b[i] != 0 and t != const):
			return False
	return True
for _ in range(int(input())):
	print('YES' if f() else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = None
	f = False
	for i in range(n):
		if b[i] != 0:
			d = a[i] - b[i]
			break
	if d == None:
		print('YES')
	elif d < 0:
		print('NO')
	else:
		for i in range(n):
			if b[i] != 0:
				if a[i] - b[i] != d:
					print('NO')
					f = True
					break
			elif a[i] > d:
				print('NO')
				f = True
				break
		if f == False:
			print('YES')


k = int(input())
for l in range(k):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = []
	z = []
	flag = 0
	for g in range(n):
		if b[g] == 0:
			z.append(a[g])
		else:
			c = a[g] - b[g]
			if c < 0:
				flag = 1
				break
			d.append(c)
	if flag == 1:
		print('NO')
		continue
	if len(d) > 0:
		f = d[0]
		flag2 = 0
		for y in d:
			if f != y:
				flag2 = 1
				break
		if flag2 == 1:
			print('NO')
			continue
		flag3 = 0
		for g in z:
			if g > f:
				flag3 = 1
				break
		if flag3 == 1:
			print('NO')
			continue
	print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sepration = 0
	flag = False
	pFlag = False
	check = []
	if n != 1:
		for i in range(n):
			if b[i] != 0:
				if a[i] >= b[i]:
					temp = a[i] - b[i]
					if not flag:
						seperation = temp
						flag = True
						continue
					elif seperation != temp:
						print('NO')
						pFlag = True
						break
				else:
					print('NO')
					pFlag = True
					break
			else:
				check.append(a[i])
		if flag and (not pFlag):
			if len(check) != 0 and len(check) != n:
				maxi = max(check)
				if seperation >= maxi:
					print('YES')
				else:
					print('NO')
			else:
				print('YES')
		elif len(check) == n:
			print('YES')
	elif a[0] >= b[0]:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = -1
	st = []
	for i in range(n):
		if a[i] < b[i]:
			print('NO')
			return 0
		if b[i] == 0:
			d = max(d, a[i])
		else:
			st.append(a[i] - b[i])
	ed = set(st)
	ls = list(ed)
	if len(ed) == 0 or (len(ls) == 1 and d <= ls[0]):
		print('YES')
	else:
		print('NO')
cf = int(input())
for i in range(cf):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr_a = list(map(int, input().split()))
	arr_b = list(map(int, input().split()))
	idx = -1
	for i in range(n):
		if arr_b[i] != 0:
			idx = i
			break
	ans = 'YES'
	if idx != -1:
		d = arr_a[idx] - arr_b[idx]
		for i in range(n):
			curr_d = arr_a[i] - arr_b[i]
			if curr_d < 0:
				ans = 'NO'
				break
			elif arr_b[i] == 0:
				if curr_d > d:
					ans = 'NO'
					break
			elif arr_b[i] != 0:
				if curr_d != d:
					ans = 'NO'
					break
	print(ans)


def verdict(n, a, b):
	d = 1000000000000
	flag = 0
	for i in range(n):
		if a[i] != 0 and b[i] != 0:
			d = a[i] - b[i]
			break
	for (x, y) in zip(a, b):
		if x < y:
			flag = 1
		elif y == 0:
			if x > d:
				flag = 1
		elif x - y != d:
			flag = 1
		if flag:
			return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	print(verdict(n, a, b))


def il():
	return list(map(int, input().split()))
import math

def ii():
	return int(input())
same = lambda s: s.count(s[0]) == len(s)

def solve(n, a, b):
	s = []
	m = []
	if n == 1:
		if a[0] < b[0]:
			return 'NO'
		else:
			return 'YES'
	elif a == b:
		return 'YES'
	elif b.count(b[0]) == len(b) and b[0] == 0:
		return 'YES'
	else:
		for i in range(n):
			if a[i] < b[i]:
				return 'NO'
			elif b[i] == 0:
				m.append(a[i] - b[i])
			else:
				s.append(a[i] - b[i])
	if len(s) > 0:
		if same(s):
			for i in range(len(m)):
				if m[i] > s[0]:
					return 'NO'
		else:
			return 'NO'
	return 'YES'
t = ii()
for _ in range(t):
	n = ii()
	a = il()
	b = il()
	print(solve(n, a, b))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = -1
	for i in range(n):
		if b[i] != 0:
			ans = i
			break
	if ans == -1:
		print('YES')
	else:
		temp = a[ans] - b[ans]
		if a[ans] < b[ans]:
			print('NO')
		else:
			ans = 1
			for i in range(n):
				if b[i] == 0 and a[i] <= temp:
					continue
				elif a[i] - b[i] != temp:
					ans = 0
					break
			print('YES') if ans == 1 else print('NO')


def determine(n, a, b):
	if sum(b) == 0:
		return 'YES'
	j = 0
	while b[j] == 0:
		j += 1
	d = a[j] - b[j]
	if d < 0:
		return 'NO'
	for j in range(n):
		if max(0, a[j] - d) != b[j]:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	print(determine(n, a, b))


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

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	net = []
	for i in range(n):
		if A[i] < B[i]:
			print('NO')
			return
		elif B[i] == 0:
			continue
		net.append(A[i] - B[i])
	if len(set(net)) > 1:
		print('NO')
		return
	for i in range(n):
		if B[i] == 0:
			d = A[i] - B[i]
			if net != [] and d > net[0]:
				print('NO')
				return
	print('YES')
t = int(input())
while t != 0:
	solve()
	t -= 1


def sol(n, a, b):
	x = None
	for i in range(n):
		x = a[i] - b[i]
		if x < 0:
			return 'NO'
		if b[i] != 0:
			break
	if b == [0] * n:
		return 'YES'
	for i in range(n):
		rr = a[i] - b[i]
		if rr < 0:
			return 'NO'
		elif rr == x:
			pass
		elif rr <= x:
			if b[i] != 0:
				return 'NO'
			else:
				pass
		else:
			return 'NO'
	return 'YES'
t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(sol(n, a, b))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [i - j for (i, j) in zip(a, b)]
	m = max(c)
	mm = min(c)
	o = 1
	if mm >= 0:
		for i in range(n):
			if b[i] == 0:
				pass
			elif a[i] - b[i] != m:
				o = 0
				break
	else:
		o = 0
	if o == 1:
		print('YES')
	else:
		print('NO')


def is_possible(n, a, b):
	(zero_diff, diff) = (-1, -1)
	for i in range(n):
		if b[i] == 0:
			zero_diff = max(zero_diff, a[i])
		elif diff == -1:
			diff = a[i] - b[i]
			if diff < 0:
				return 'NO'
		elif diff != a[i] - b[i] or diff < 0:
			return 'NO'
		if zero_diff != -1 and diff != -1:
			if diff < zero_diff:
				return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(is_possible(n, a, b))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	b_not_zero_diff = None
	for (a_val, b_val) in zip(a, b):
		if b_val != 0:
			b_not_zero_diff = a_val - b_val
			break
	if b_not_zero_diff == None:
		print('YES')
		continue
	found_error = False
	for (a_val, b_val) in zip(a, b):
		if b_val > a_val:
			print('NO')
			found_error = True
			break
		current_diff = a_val - b_val
		if b_val != 0 and current_diff != b_not_zero_diff or (b_val == 0 and current_diff > b_not_zero_diff):
			found_error = True
			print('NO')
			break
	if not found_error:
		print('YES')


t = int(input())
for i in range(t):
	flag = False
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	key = max(a) - max(b)
	if key < 0:
		flag = True
	if key == 0:
		if a == b:
			print('YES')
			continue
		else:
			flag = True
	for i in range(0, n):
		if not (a[i] - b[i] == key or (b[i] == 0 and a[i] - b[i] <= key)):
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


def exe():
	for i in range(n):
		if b[i] != 0:
			diff = a[i] - b[i]
			break
	else:
		return 'YES'
	if diff < 0:
		return 'NO'
	for i in range(n):
		if a[i] - b[i] != diff:
			if b[i] == 0:
				if a[i] - b[i] < diff:
					pass
				else:
					return 'NO'
			else:
				return 'NO'
	return 'YES'
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(exe())


def solve():
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for i in range(len(b)):
		if b[i] > a[i]:
			print('NO')
			return
	maxdiff = 0
	for i in range(n):
		if a[i] - b[i] > maxdiff:
			maxdiff = a[i] - b[i]
	for i in range(n):
		a[i] -= maxdiff
		if a[i] < 0:
			a[i] = 0
	for i in range(0, len(b)):
		if b[i] != a[i]:
			print('NO')
			return
	print('YES')
t = int(input())
for i in range(t):
	solve()


def answer(a, b, c, n):
	if c < 0:
		return 'NO'
	for i in range(n):
		if b[i] == 0:
			if a[i] - b[i] > c:
				return 'NO'
		elif a[i] - b[i] != c:
			return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 20000000000
	for i in range(n):
		if b[i] != 0:
			c = a[i] - b[i]
			break
	print(answer(a, b, c, n))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {i - j for (i, j) in zip(a, b) if j}
	if len(d) == 0:
		print('YES')
	elif len(d) > 1 or list(d)[0] < 0:
		print('NO')
	else:
		print('YES' if max((i for (i, j) in zip(a, b) if not j), default=0) <= list(d)[0] else 'NO')


for _ in range(int(input())):
	input()
	(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
	non_zero_deltas = [i - j for (i, j) in zip(a, b) if j != 0]
	zero_deltas = [i for (i, j) in zip(a, b) if j == 0]
	res = 'YES'
	if len(non_zero_deltas) > 0 and (any([i < 0 for i in non_zero_deltas]) or len(set(non_zero_deltas)) > 1):
		res = 'NO'
	elif len(non_zero_deltas) == 0:
		res = 'YES'
	elif len(zero_deltas) > 0 and any([i > non_zero_deltas[0] for i in zero_deltas]):
		res = 'NO'
	print(res)


import math
for h in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	if y.count(0) == n:
		print('YES')
		continue
	m = 100000
	for i in range(n):
		if x[i] < y[i]:
			m = -1
			break
		if y[i] != 0:
			m = x[i] - y[i]
	if m < 0:
		print('NO')
		continue
	f = True
	for i in range(n):
		if y[i] == 0 and x[i] - y[i] <= m:
			a = 1
		elif y[i] != 0 and x[i] - y[i] == m:
			a = 1
		else:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	e = 0
	ind = -1
	for j in range(n):
		if lstb[j] != 0:
			ind = j
			break
	if ind == -1:
		print('YES')
	else:
		ele = lsta[ind] - lstb[ind]
		c = 0
		for j in range(n):
			if lstb[j] == 0:
				d = lsta[j]
				if d > ele:
					e += 1
					break
				else:
					c += 1
			else:
				d = lsta[j] - lstb[j]
				if d != ele:
					e += 1
					break
				else:
					c += 1
		if e > 0 or ele < 0:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(0, t):
	n = int(input())
	list1 = [int(num) for num in input().split()]
	list2 = [int(num) for num in input().split()]
	flag = 0
	for i in range(0, len(list2)):
		if list2[i] != 0:
			ind = i
			flag = 1
			break
	if flag == 0:
		print('YES')
	elif list1[ind] < list2[ind]:
		print('NO')
	else:
		diff = list1[ind] - list2[ind]
		flag = 0
		for i in range(0, len(list1)):
			if list1[i] < list2[i]:
				flag = 1
				break
			elif list2[i] != 0:
				d = list1[i] - list2[i]
				if d != diff:
					flag = 1
					break
			else:
				d = list1[i] - list2[i]
				if d > diff:
					flag = 1
					break
		if flag == 1:
			print('NO')
		else:
			print('YES')


def check(a, b):
	x = None
	for i in range(len(a)):
		if b[i] > a[i]:
			return False
		elif b[i] != 0:
			if x is None:
				x = a[i] - b[i]
			elif x != a[i] - b[i]:
				return False
	for i in range(len(a)):
		if b[i] == 0:
			if x is not None:
				if a[i] > x:
					return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if check(a, b):
		print('YES')
	else:
		print('NO')


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = -1
	for i in range(n):
		if b[i] != 0:
			d = a[i] - b[i]
			break
	ans = 'YES'
	if d < 0 and max(b) != 0:
		ans = 'NO'
	elif max(b) != 0:
		for i in range(n):
			if a[i] - b[i] != d and b[i] != 0:
				ans = 'NO'
				break
			elif a[i] - b[i] > d and b[i] == 0:
				ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	val = float('inf')
	flag = 0
	ma = float('-inf')
	for i in range(n):
		if b[i] != 0:
			if val == float('inf'):
				val = a[i] - b[i]
				if val < 0:
					flag = 1
					break
			elif a[i] - b[i] == val:
				continue
			else:
				flag = 1
				break
		else:
			ma = max(ma, a[i])
	if flag == 0 and ma <= val:
		print('YES')
	else:
		print('NO')


n = int(input())

def YES_OR_NO(a, b, op):
	n = len(a)
	for i in range(n):
		if a[i] <= op:
			if b[i] != 0:
				return 'NO'
			else:
				continue
		elif a[i] - b[i] != op:
			return 'NO'
		else:
			continue
	return 'YES'
for i in range(n):
	x = input()
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	op = None
	for j in range(len(b)):
		if b[j] != 0:
			op = a[j] - b[j]
			break
	if op == None:
		print('YES')
	elif op < 0:
		print('NO')
	else:
		print(YES_OR_NO(a, b, op))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	dif = -1
	p = True
	if len(set(b)) == 1 and b[0] == 0:
		print('YES')
		continue
	if False:
		print('Tanmay')
	for i in range(n):
		if b[i] != 0:
			dif = a[i] - b[i]
			break
	for i in range(n):
		if a[i] < b[i]:
			p = False
			break
		if b[i] != max(a[i] - dif, 0):
			p = False
			break
	if p:
		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()))
	if set(b) == {0}:
		print('YES')
	else:
		l = []
		flag = False
		for i in range(n):
			if b[i] > a[i]:
				flag = True
				break
			l += [a[i] - b[i]]
		if flag:
			print('NO')
			continue
		mx = max(l)
		for i in range(n):
			if l[i] == mx:
				continue
			elif l[i] < mx:
				if b[i] == 0:
					continue
				break
			else:
				break
		else:
			print('YES')
			continue
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	lst3 = []
	lst4 = []
	c = 0
	for i in range(n):
		a = lst1[i]
		b = lst2[i]
		if b > a:
			c = c + 1
			break
		if b == 0:
			lst4.append(a - b)
		else:
			lst3.append(a - b)
	v = list(set(lst3))
	if c > 0:
		print('NO')
	elif len(v) > 1:
		print('NO')
	elif len(lst4) == 0:
		if len(v) == 1:
			print('YES')
		else:
			print('NO')
	elif len(lst3) == 0:
		print('YES')
	else:
		a = max(lst3)
		b = max(lst4)
		if b <= a:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	while i < len(a):
		if a[i] >= b[i]:
			if b[i] != 0:
				d = a[i] - b[i]
				break
			i += 1
		else:
			break
	flag = 0
	if i == len(a):
		print('YES')
	else:
		for j in range(len(a)):
			if a[j] < b[j]:
				print('NO')
				flag = 1
				break
			elif b[j] != 0:
				if d != a[j] - b[j]:
					print('NO')
					flag = 1
					break
			elif d < a[j] - b[j]:
				print('NO')
				flag = 1
				break
		if flag == 0:
			print('YES')


t = int(input())
for case in range(t):
	n = int(input())
	d1 = list(map(int, input().split()))
	d2 = list(map(int, input().split()))
	m = d1.index(max(d1))
	dif = d1[m] - d2[m]
	if dif < 0:
		print('NO')
		continue
	flag = False
	for i in range(n):
		if d1[i] >= dif:
			if d1[i] - d2[i] != dif:
				flag = True
				break
		elif d2[i] != 0:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


import math

def ans(a, b):
	ans = set()
	m = float('-inf')
	for (i, j) in zip(a, b):
		if j == 0:
			m = max(m, i)
		elif j > i:
			print('NO')
			return
		else:
			ans.add(i - j)
	if len(ans) > 1:
		print('NO')
		return
	x = list(ans)
	if x and x[0] < m:
		print('NO')
		return
	print('YES')
	return
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()]
	ans(a, b)


for _ in range(int(input())):
	j = 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	m = max(a)
	i = a.index(m)
	k = a[i] - b[i]
	for c in range(n):
		if a[c] < b[c]:
			j = -1
			break
		elif a[c] - k < 0 and b[c] == 0:
			continue
		elif a[c] - k == b[c]:
			continue
		else:
			j = -1
			break
	if j > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for blahblah in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = set()
	temp_zero = -1
	flag = 0
	if sum(b) == 0:
		flag = 1
	else:
		for i in range(n):
			difference = a[i] - b[i]
			if difference < 0:
				flag = 0
				break
			if b[i] == 0:
				if difference >= temp_zero:
					temp_zero = difference
			else:
				c.add(difference)
				if len(c) > 1:
					flag = 0
					break
			flag = 1
		if len(c) != 0:
			if list(c)[0] < temp_zero:
				flag = 0
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	k = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dif = max(a) - max(b)
	if dif < 0:
		print('NO')
	else:
		c = 0
		for i in range(k):
			if b[i] == 0 and a[i] < dif:
				c += 1
			elif a[i] - b[i] == dif:
				c += 1
			else:
				break
		if c == k:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	arr1 = list(map(int, input().split(' ')[:n]))
	arr2 = list(map(int, input().split(' ')[:n]))
	maxele1 = max(arr1)
	maxele2 = max(arr2)
	if maxele1 < maxele2:
		print('NO')
	else:
		diff = maxele1 - maxele2
		for i in range(n):
			arr1[i] -= diff
		for i in range(n):
			if arr1[i] < 0:
				arr1[i] = 0
		if arr1 == arr2:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a1 = [int(i) for i in input().split()]
	b1 = [int(i) for i in input().split()]
	a = max(a1) - max(b1)
	if a < 0:
		print('NO')
		continue
	a1 = [max(0, i - a) for i in a1]
	if a1 == b1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	j = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 0
	flag = 0
	n = []
	z = [0]
	if j == 1:
		if a[k] >= b[k]:
			print('YES')
			continue
		else:
			print('NO')
			continue
	while k < j:
		if b[k] != 0:
			if a[k] >= b[k]:
				n.append(a[k] - b[k])
				k += 1
			else:
				print('NO')
				flag = 1
				break
		else:
			z.append(a[k] - b[k])
			k += 1
	if flag == 1:
		continue
	elif set(n).__len__() == 1 and n[0] >= max(z):
		print('YES')
	elif set(n).__len__() == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	am = max(a)
	idx = a.index(am)
	bm = b[idx]
	dm = am - bm
	if dm < 0:
		ans.append('NO')
		continue
	flag = 0
	for i in range(len(a)):
		d = a[i] - dm
		if d == b[i]:
			continue
		elif d <= 0 and b[i] == 0:
			continue
		else:
			ans.append('NO')
			flag = 1
			break
	if flag == 1:
		continue
	ans.append('YES')
for i in ans:
	print(i)


t = int(input())
i = 0
res = []
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	big_diff = max(a) - b[a.index(max(a))]
	flag = 'YES'
	if big_diff < 0:
		flag = 'NO'
	else:
		for x in range(len(a)):
			diff = a[x] - big_diff
			if diff != b[x]:
				if diff < 0 and b[x] == 0:
					pass
				else:
					flag = 'NO'
					break
	res.append(flag)
	i += 1
for x in res:
	print(x)


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

def minp():
	return map(int, input().split())

def iinp():
	return int(input())

def test():
	return int(input())

def inp():
	return input()

def solve():
	n = iinp()
	a = linp()
	b = linp()
	dif = []
	zdif = []
	for i in range(n):
		if b[i]:
			dif.append(a[i] - b[i])
		else:
			zdif.append(a[i])
	if zdif:
		k = max(zdif)
	else:
		k = 0
	if dif:
		m = max(dif)
		mi = min(dif)
		if m == mi:
			if k <= m:
				return 'YES'
			else:
				return 'NO'
		else:
			return 'NO'
	else:
		return 'YES'

def main():
	for _ in range(test()):
		print(solve())
main()


def check(A, B, n):
	diff = A[0] - B[0]
	for i in range(n):
		d = A[i] - B[i]
		if d < 0:
			return False
		if d > diff:
			diff = d
	for i in range(n):
		if B[i] != 0 and A[i] - B[i] != diff:
			return False
	return True
tests = int(input())
for _ in range(tests):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if check(A, B, n):
		print('YES')
	else:
		print('NO')


tc = int(input())
while tc > 0:
	flag = 0
	n = int(input())
	A = [int(i) for i in input().split(' ')]
	B = [int(i) for i in input().split(' ')]
	x = 0
	for i in range(n):
		if B[i] != 0:
			x = A[i] - B[i]
			flag = 1
			break
	if x < 0:
		print('NO')
	elif flag == 0:
		print('YES')
	else:
		flag = 0
		for i in range(n):
			if not (A[i] - B[i] == x or (B[i] == 0 and A[i] - B[i] < x)):
				flag = 1
		if flag == 0:
			print('YES')
		else:
			print('NO')
	tc = tc - 1


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	datb = list(map(int, input().split()))
	d = max(data) - max(datb)
	if d < 0:
		print('NO')
		continue
	datc = list(map(lambda x: max(0, x - d), data))
	if datb == datc:
		print('YES')
	else:
		print('NO')


def solve(n):
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	diff = [0] * n
	for i in range(n):
		diff[i] = a[i] - b[i]
	actDiff = None
	for i in range(n):
		if diff[i] < 0:
			print('NO')
			return
		if b[i] != 0:
			if actDiff == None:
				actDiff = diff[i]
			elif actDiff != diff[i]:
				print('NO')
				return
	if actDiff == None:
		print('YES')
		return
	for i in range(n):
		if b[i] == 0 and diff[i] > actDiff:
			print('NO')
			return
	print('YES')
t = int(input())
for i in range(t):
	solve(int(input()))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = max(a) - max(b)
	if a1 < 0:
		print('NO')
		continue
	a = [max(0, i - a1) for i in a]
	if a == b:
		print('YES')
	else:
		print('NO')


def inp(*, cf=lambda x: x):
	return cf(input())

def inpint():
	return inp(cf=int)

def inp_line(*, cf=lambda x: x, s=' '):
	return list(map(cf, input().split(s)))

def inpints():
	return inp_line(cf=int)

def intstostr(l):
	return ' '.join([str(x) for x in l])

def listtostr(l):
	return ' '.join(l)

def test_case(case):
	n = inpint()
	a = inpints()
	b = inpints()
	diff = -1
	for i in range(n):
		if b[i] == 0:
			continue
		if a[i] - b[i] < 0:
			return 'NO'
		if diff == -1:
			diff = a[i] - b[i]
		if a[i] - b[i] != diff:
			return 'NO'
	if diff == -1:
		return 'YES'
	for i in range(n):
		if b[i] == 0 and a[i] - b[i] > diff:
			return 'NO'
	return 'YES'

def main():
	T = inpint()
	for t in range(1, T + 1):
		print(test_case(t))
main()


import sys, math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_ls():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve(a, b, n):
	for i in range(n):
		if a[i] < b[i]:
			return False
	diff = math.inf
	for i in range(n):
		if b[i] != 0:
			diff = min(diff, a[i] - b[i])
	if diff == math.inf:
		return True
	for i in range(n):
		if a[i] - b[i] > diff:
			return False
		if b[i] != 0 and a[i] - b[i] < diff:
			return False
	return True

def main():
	for _ in range(int(input())):
		n = int(input())
		a = get_ls()
		b = get_ls()
		print('YES' if solve(a, b, n) else 'NO')
main()


col = int(input())
for i in range(col):
	t = int(input())
	sp1 = list(map(int, input().split()))
	sp2 = list(map(int, input().split()))
	for j in range(t):
		if sp2[j] != 0:
			r = sp1[j] - sp2[j]
			break
	else:
		print('YES')
		continue
	if r < 0:
		print('NO')
	else:
		for j in range(t):
			if sp2[j] != 0:
				if sp1[j] - r != sp2[j]:
					print('NO')
					break
			elif sp1[j] > r:
				print('NO')
				break
		else:
			print('YES')


T = int(input())
for _ in range(T):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	mx = max([l1[i] - l2[i] for i in range(n)])
	ok = mx
	for i in range(n):
		l = l1[i] - l2[i]
		if l != mx and l2[i] != 0:
			ok = -1
			break
	if ok >= 0:
		print('YES')
	else:
		print('NO')


def f():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	limit1 = 0
	limit2 = -1
	for i in range(n):
		if a[i] < b[i]:
			return 'NO'
		if b[i] == 0:
			limit1 = max(a[i], limit1)
		elif limit2 == -1 or limit2 == a[i] - b[i]:
			limit2 = a[i] - b[i]
		else:
			return 'NO'
	if limit2 == -1:
		return 'YES'
	if limit2 < limit1:
		return 'NO'
	return 'YES'
t = input()
for i in range(int(t)):
	print(f())


def solve(a, b):
	ans = max(a) - max(b)
	if ans < 0:
		return 'NO'
	for i in range(len(a)):
		if b[i] == 0:
			if a[i] - b[i] <= ans:
				continue
			else:
				return 'NO'
		elif a[i] == 0 and b[i] != 0:
			return 'NO'
		elif a[i] - b[i] != ans:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(a, b))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(d1, d2) = ([], [])
	on = 0
	for i in range(n):
		p = a[i] - b[i]
		if b[i] == 0:
			d2.append(p)
		else:
			d1.append(p)
		if p < 0:
			on = 1
			break
	if on:
		print('NO')
		continue
	if len(d1) == 0:
		print('YES')
	elif len(d2) == 0:
		if len(set(d1)) == 1:
			print('YES')
		else:
			print('NO')
	else:
		(q, r) = (max(d2), min(d1))
		s = len(set(d1))
		if s == 1:
			if q <= r:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')