You're given two arrays $a[1 \dots n]$ and $b[1 \dots n]$, both of the same length $n$.

In order to perform a push operation, you have to choose three integers $l, r, k$ satisfying $1 \le l \le r \le n$ and $k > 0$. Then, you will add $k$ to elements $a_l, a_{l+1}, \ldots, a_r$.

For example, if $a = [3, 7, 1, 4, 1, 2]$ and you choose $(l = 3, r = 5, k = 2)$, the array $a$ will become $[3, 7, \underline{3, 6, 3}, 2]$.

You can do this operation at most once. Can you make array $a$ equal to array $b$?

(We consider that $a = b$ if and only if, for every $1 \le i \le n$, $a_i = b_i$)


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 20$) — the number of test cases in the input.

The first line of each test case contains a single integer $n$ ($1 \le n \le 100\ 000$) — the number of elements in each array.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 1000$).

The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 1000$).

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$.


-----Output-----

For each test case, output one line containing "YES" if it's possible to make arrays $a$ and $b$ equal by performing at most once the described operation or "NO" if it's impossible.

You can print each letter in any case (upper or lower).


-----Example-----
Input
4
6
3 7 1 4 1 2
3 7 3 6 3 2
5
1 1 1 1 1
1 2 1 3 1
2
42 42
42 42
1
7
6

Output
YES
NO
YES
NO



-----Note-----

The first test case is described in the statement: we can perform a push operation with parameters $(l=3, r=5, k=2)$ to make $a$ equal to $b$.

In the second test case, we would need at least two operations to make $a$ equal to $b$.

In the third test case, arrays $a$ and $b$ are already equal.

In the fourth test case, it's impossible to make $a$ equal to $b$, because the integer $k$ has to be positive.

Difficulty: interview

Starter code:

Solutions:
import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
def write(*args, sep="\n"):
  for i in args:
    sys.stdout.write("{}{}".format(i, sep))
INF = float('inf')
MOD = int(1e9 + 7)

for _ in range(int(input())):
  n = int(input())
  a = list(read())
  b = list(read())

  arr = []
  for i in range(n):
    if a[i] != b[i]:
      arr.append((i, b[i] - a[i]))

  
  flag = True 
  s = []
  for i, j in arr:
    if j <= 0:
      flag = False
      break 
    s.append(j)
  
  for i in range(1, len(arr)):
    if arr[i][0] != arr[i-1][0] + 1:
      flag = False 
      break 
  
  if len(set(s)) >= 2:
    flag = False 

  if flag:
    print("YES")
  else:
    print("NO")
  


for q in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    s = list(map(int, input().split()))
    ans = -1
    for q in range(len(a)):
        if a[q] != s[q] and ans == -1:
            ans = s[q]-a[q]
            if ans < 0:
                print('NO')
                break
        elif a[q] != s[q] and (ans == -2 or ans != s[q] - a[q]):
            print('NO')
            break
        elif a[q] == s[q] and ans > 0:
            ans = -2
    else:
        print('YES')


from sys import stdin
from collections import deque
t=int(stdin.readline().strip())

for cas in range(t):
    n=int(stdin.readline().strip())
    s=list(map(int,stdin.readline().strip().split()))
    s1=list(map(int,stdin.readline().strip().split()))
    aux=deque([])
    for i in range(n):
        aux.append(s[i]-s1[i])
    l=n
    r=-1
    for i in range(n):
        if aux[i]!=0:
            l=i
            break
    for i in range(n-1,-1,-1):
        if aux[i]!=0:
            r=i
            break
    st=set()
    for i in range(l,r+1):
        st.add(aux[i])
    st=list(st)
    if len(st)==0 or (len(st)==1 and st[0]<0):
        print("YES")
    else:
        print("NO")
        
        


def solve(arr1,arr2,n):
    index = -1
    for i in range(n):
        if arr1[i] != arr2[i]:
            index = i
            diff = arr2[i]-arr1[i]
            break

    if index == -1:
        print('YES')
        return
    if diff < 0:
        print('NO')
        return
    for i in range(index,n):
        if arr1[i] == arr2[i]:
            break
        curr = arr2[i]-arr1[i]
        if curr != diff:
            print('NO')
            return
        arr2[i] = arr1[i]

    for i in range(n):
        if arr1[i] != arr2[i]:
            print('NO')
            return

    print('YES')

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

main()


q=int(input())

for qq in range(q):
    n=int(input())
    a=list(map(int, input().split()))
    b=list(map(int, input().split()))
    started = False
    ended = False
    possible = True
    diff=0
    for i in range(n):
        if a[i] != b[i]:
            if a[i] > b[i]:
                possible = False
                break
            elif ended:
                possible = False
                break
            elif started and b[i] - a[i] != diff:
                possible = False
                break
            elif started:
                continue
            elif not started:
                started = True
                diff = b[i] - a[i]
        elif a[i] == b[i] and started:
            ended = True

    if possible:
        print("YES")
    else:
        print("NO")


q = int(input())
for rwerwe in range(q):
	n = int(input())
	a = list(map(int,input().split()))
	b = list(map(int,input().split()))
	c = [b[i] - a[i] for i in range(n)]
	dupa = {}
	for i in range(n):
		if c[i] != 0:
			dupa[c[i]] = 0
	if len(dupa) > 1:
		print("NO")
	if len(dupa) == 0:
		print("YES")
	if len(dupa) == 1:
		if sum(c) < 0:
			print("NO")
		else:
			for i in range(n):
				if c[i] != 0:
					start = i
					break
			for j in range(n):
				i = n - 1 - i
				if c[j] != 0:
					end = j
			if (end-start+1)*c[start] == sum(c):
				print("YES")
			else:
				print("NO")

import sys
readline = sys.stdin.readline

T = int(readline())
Ans = [None]*T
for qu in range(T):
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = [b-a for a, b in zip(A, B)]
    while C and C[-1] == 0:
        C.pop()
    C.reverse()
    while C and C[-1] == 0:
        C.pop()
    
    if not C or (len(set(C)) == 1 and C[0] > 0):
        Ans[qu] = 'YES'
    else:
        Ans[qu] = 'NO'

print('\n'.join(map(str, Ans)))

from itertools import groupby

for _ in range(int(input())):
    n = int(input())
    a, b = list(map(int, input().split())), list(map(int, input().split()))
    diff = [y-x for x, y in zip(a, b)]

    if min(diff) < 0:
        print('NO')
        continue

    group = [len(tuple(v)) for k, v in groupby(diff) if k > 0]
    if len(group) > 1:
        print('NO')
    else:
        print('YES')

for TT in range(1, int(input()) + 1):
    n = int(input())
    a = [*map(int, input().split())]
    b = [*map(int, input().split())]
    c = [y - x for x, y in zip(a, b)]
    i = 0
    while i < n and c[i] == 0: i += 1
    j = i
    while j < n and c[j] == c[i]: j += 1
    k = j
    while k < n and c[k] == 0: k += 1
    res = i == n or (c[i] > 0 and k == n)
    print("YES" if res else "NO")

t = int(input())
for daf in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    cs = 0
    f = True
    el = -1
    for i in range(n):
        if b[i] - a[i] < 0:
            f = False
            break
        if b[i] - a[i] != 0:
            if cs == 0:
                cs = 1
                el = b[i] - a[i]
            elif cs == 1:
                if b[i] - a[i] != el:
                    f = False
                    break
            else:
                f = False
                break
        else:
            if cs == 1:
                cs = 2
    if f:
        print("YES")
    else:
        print("NO")


t = int(input())

for case in range(t):
    n = int(input())
    arr1 = list(map(int, input().split()))
    arr2 = list(map(int, input().split()))
    deltas = [0]
    delta_types = set([0])
    for i in range(len(arr2)):
        delta = arr2[i] - arr1[i]
        deltas.append(delta)
        delta_types.add(delta)
    if len(delta_types) > 2:
        print("NO")
    elif len(delta_types) == 1:
        print("YES")
    else:
        min_delta = min(delta_types)
        if min_delta < 0:
            print("NO")
        else:
            num_change = 0
            for i in range(len(deltas) - 1):
                if deltas[i] == 0 and deltas[i + 1] != 0:
                    num_change += 1
            if num_change == 1:
                print("YES")
            else:
                print("NO")


import math
from decimal import Decimal
import heapq
from collections import deque
def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return n,b
 
 
def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return n,b,c
 
 
def dv():
	n, m = list(map(int, input().split()))
	return n,m
 
 
def dva():
	n, m = list(map(int, input().split()))
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return n,m,b
 
 
def eratosthenes(n): 
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))
 
 
def lol(lst,k):
	k=k%len(lst)
	ret=[0]*len(lst)
	for i in range(len(lst)):
		if i+k<len(lst) and i+k>=0:
			ret[i]=lst[i+k]
		if i+k>=len(lst):
			ret[i]=lst[i+k-len(lst)]
		if i+k<0:
			ret[i]=lst[i+k+len(lst)]
	return(ret)
def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return n,b,m,c
 
 
def dvs():
	n = int(input())
	m = int(input())
	return n, m 
 
def fact(a, b):
	c = []
	ans = 0
	f = int(math.sqrt(a))
	for i in range(1, f + 1):
		if a % i == 0:
			c.append(i)
	l = len(c)
	for i in range(l):
		c.append(a // c[i])
	for i in range(len(c)):
		if c[i] <= b:
			ans += 1
	if a / f == f and b >= f:
		return ans - 1
	return ans
 

t = int(input())
for i in range(t):
	n, a = na()
	b = list(map(int, input().split()))
	c = []
	f = True
	s = set()
	for j in range(n):
		if a[j] != b[j]:
			if a[j] > b[j]:
				print('NO')
				f = False
				break
			c.append(j)
			s.add(a[j] - b[j])
	if f:
			if len(s) > 1:
				print('NO')
				continue
			f = True
			for j in range(len(c) - 1):
				if c[j] != c[j + 1] - 1:
					f = False
			if f:
				print('YES')
			else:
				print('NO')


import sys
input = sys.stdin.readline

t=int(input())
for testcases in range(t):
    n=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))

    C=[B[i]-A[i] for i in range(n)]

    MAX=max(C)
    if min(C)<0:
        print("NO")
        continue
    
    if MAX==0:
        print("YES")
        continue

    for c in C:
        if 0<c<MAX:
            print("NO")
            break

    else:
        D=[]
        for i in range(n):
            if C[i]==MAX:
                D.append(i)

        if len(D)<=1:
            print("YES")
            continue

        for j in range(1,len(D)):
            if D[j]!=D[j-1]+1:
                print("NO")
                break
        else:
            print("YES")
            
        

    


t = int(input())
for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [b[i] - a[i] for i in range(n)]
    last = None
    fail = False
    if any(x < 0 for x in c): fail = True
    for item in c:
        if last == None:
            if item == 0: continue
            else: last = item
        else:
            if item == 0:
                last = 0
            else:
                if item != last:
                    fail = True
                    break

    if fail:
        print("NO")
    else:
        print("YES")
            


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int,minp().split()))

def solve():
	n = mint()
	a = list(mints())
	b = list(mints())
	diff = None
	last = 0
	for i in range(n):
		if b[i] != a[i]:
			last = i
	
	for i in range(n):
		d = b[i] - a[i]
		if diff != None and i <= last and d != diff:
			return False
		if d != 0:
			if d < 0:
				return False
			diff = d
	return True

for i in range(mint()):
	print(['NO','YES'][solve()])


# @author 

import sys

class ASinglePush:
    def solve(self):
        t = int(input())
        for _ in range(t):
            n = int(input())
            a = [int(_) for _ in input().split()]
            b = [int(_) for _ in input().split()]
            u = [b[i] - a[i] for i in range(n)]
            l = -1
            r = -1
            for i in range(n):
                if u[i]:
                    l = i
                    break

            for i in range(n - 1, -1, -1):
                if u[i]:
                    r = i
                    break

            if l == -1:
                print("YES")
            else:
                assert(l != -1 and r != -1)
                # print(u[l:r + 1], l, r)
                print("YES" if u[l] > 0 and u[l:r + 1] == [u[l]] * (r - l + 1) else "NO")

solver = ASinglePush()
input = sys.stdin.readline

solver.solve()


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()))
    f = []
    p = None
    for d in (x - y for x, y in zip(a, b)):
        if d != p and (d != 0 or f):
            f.append(d)
        p = d
    while f and f[-1] == 0:
        f.pop()
    print('YES' if not f or len(f) == 1 and f[0] < 0 else 'NO')

q = int(input())
for i in range(q):
	n = int(input())
	mas1 = list(map(int, input().split()))
	mas2 = list(map(int, input().split()))
	flag = 0
	al = True
	p = 0
	for j in range(n):
		if mas1[j] != mas2[j]:
			if flag == 0:
				flag = 1
				p = mas1[j] - mas2[j]
				if p > 0:
					al = False
					break
			elif flag == 1:
				if p != mas1[j] - mas2[j]:
					al = False
					break
			else:
				al = False
				break
		else:
			if flag == 1:
				flag = 2
	if al:
		print("YES")
	else:
		print ("NO")


t = int(input())
for i in range(t):
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    ans = []
    for i in range(n):
        if a[i] != b[i]:
            ans.append(i)
    f = False
    for i in range(1, len(ans)):
        if ans[i] - ans[i - 1] != 1:
            f = True
    if f:
        print("NO")
    else:
        if len(ans) == 0:
            print("YES")
        else:
            f = False
            now = a[ans[0]] - b[ans[0]]
            for i in range(1, len(ans)):
                if now != a[ans[i]] - b[ans[i]]:
                    f = True
            if f or now > 0:
                print("NO")
            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()))
    diff = -1
    for i in range(n):
        if a[i] == b[i]:
            if diff == -1:
                continue
            else:
                diff = 10**9
        else:
            if diff == -1:
                diff = b[i] - a[i]
                if diff < 0:
                    print("NO")
                    break
            if diff != -1:
                if diff == b[i] - a[i]:
                    continue
                else:
                    print("NO")
                    break
    else:
        print("YES")

# from sys import stdin
# def rl():
#     return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
# map(int,input().split())
# # l = list(map(int,input().split()))
# from itertools import permutations
import sys
input = sys.stdin.readline

t = int(input())

for _ in range(t):
    n = int(input())
    l1 = list(map(int,input().split()))
    l2 = list(map(int,input().split()))
    count = 0
    i = 0
    while i<n:
        if l1[i]!=l2[i]:
            j = i

            count+=1
            if count == 2:
                break
            seti = set()
            while l1[j]!=l2[j]:
                seti.add((l2[j]-l1[j]))
                j+=1
                if j == n:
                    break
            i = j
            if j == n:
               break

        else:
            i+=1

    # print(seti)
    if count == 1:
        if len(seti) == 1:
            z = seti.pop()
            if z>0:
             print('YES')
            else:
                print('NO')
        else:
            print('NO')
    elif count == 0:
        print('YES')

    else:
        print('NO')






'''
Name : Jaymeet Mehta
id :mj_13
Problem : Single push
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    N=int(stdin.readline())
    A= [int(x) for x in stdin.readline().split()]
    B= [int(x) for x in stdin.readline().split()]
    indices=[]
    values=[]
    flag=True
    for i in range(N):
        if A[i]!=B[i]:
            if B[i]<A[i]:
                flag=False
                break
            values.append(B[i]-A[i])
            indices.append(i)
    if not flag:
        print("NO")
        continue
    if len(set(values))>1:
        flag=False
    for i in range(1,len(indices)):
        if indices[i]-indices[i-1]!=1:
            flag=False
            break
    print("YES") if flag else print("NO")

import math

t = int(input())

for f in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    cnt = [0] * n


    for i in range(n):
        cnt[i] = b[i] - a[i]

    u = [True] * n
    l, r = 0, 0
    for i in range(n):
        if cnt[i] != 0:
            l = i
            break
    for i in range(n - 1, -1, -1):
        if cnt[i] != 0:
            r = i
            break

    el = cnt[l]
    ans = True
    for i in range(l, r + 1):
        if cnt[i] != el or cnt[i] < 0:
            ans = False

    if ans:
        print('YES')
    else:
        print('NO')








from itertools import groupby
T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = []
    for a, b in zip(A, B):
        C.append(b-a)
    D = []
    for v, g in groupby(C):
        D.append(v)
    if len(D)==1:
        if D[0] >= 0:
            print("YES")
        else:
            print("NO")
    elif len(D)==2:
        if 0 in D:
            D.remove(0)
            if D[0]>=0:
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
    elif len(D)==3:
        if D[0]==D[-1]==0 and D[1]>=0:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")