Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:

There are two arrays of integers $a$ and $b$ of length $n$. It turned out that array $a$ contains only elements from the set $\{-1, 0, 1\}$.

Anton can perform the following sequence of operations any number of times:  Choose any pair of indexes $(i, j)$ such that $1 \le i < j \le n$. It is possible to choose the same pair $(i, j)$ more than once.   Add $a_i$ to $a_j$. In other words, $j$-th element of the array becomes equal to $a_i + a_j$. 

For example, if you are given array $[1, -1, 0]$, you can transform it only to $[1, -1, -1]$, $[1, 0, 0]$ and $[1, -1, 1]$ by one operation.

Anton wants to predict if it is possible to apply some number (zero or more) of these operations to the array $a$ so that it becomes equal to array $b$. Can you help him?


-----Input-----

Each test contains multiple test cases. 

The first line contains the number of test cases $t$ ($1 \le t \le 10000$). The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1 \le n \le 10^5$)  — the length of arrays.

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($-1 \le a_i \le 1$)  — elements of array $a$. There can be duplicates among elements.

The third line of each test case contains $n$ integers $b_1, b_2, \dots, b_n$ ($-10^9 \le b_i \le 10^9$)  — elements of array $b$. There can be duplicates among elements.

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 the described operations, or "NO" if it's impossible.

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


-----Example-----
Input
5
3
1 -1 0
1 1 -2
3
0 1 1
0 2 2
2
1 0
1 41
2
-1 0
-1 -41
5
0 1 -1 1 -1
1 1 -1 1 -1

Output
YES
NO
YES
YES
NO



-----Note-----

In the first test-case we can choose $(i, j)=(2, 3)$ twice and after that choose $(i, j)=(1, 2)$ twice too. These operations will transform $[1, -1, 0] \to [1, -1, -2] \to [1, 1, -2]$

In the second test case we can't make equal numbers on the second position.

In the third test case we can choose $(i, j)=(1, 2)$ $41$ times. The same about the fourth test case.

In the last lest case, it is impossible to make array $a$ equal to the array $b$.

Difficulty: EASY

Solutions:
import collections

def solve(n, arrA, arrB):
	seen = set()
	for (i, (a, b)) in enumerate(zip(arrA, arrB)):
		diff = b - a
		if diff > 0:
			if 1 not in seen:
				return False
		elif diff < 0:
			if -1 not in seen:
				return False
		seen.add(a)
	return True
t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	arrA = list(map(int, input().strip().split()))
	arrB = list(map(int, input().strip().split()))
	print('YES' if solve(n, arrA, arrB) else 'NO')


from sys import stdin
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	l1 = []
	l2 = []
	l3 = []
	(c1, c2, c3) = (0, 0, 0)
	for j in a:
		if j == -1:
			c1 += 1
		if j == 0:
			c2 += 1
		if j == 1:
			c3 += 1
		l1.append(c1)
		l2.append(c2)
		l3.append(c3)
	if a[0] != b[0]:
		print('NO')
	else:
		ans = 'YES'
		for j in range(n - 1, 0, -1):
			if b[j] != a[j]:
				if b[j] - a[j] > 0:
					if l3[j - 1] == 0:
						ans = 'NO'
				elif l1[j - 1] == 0:
					ans = 'NO'
		print(ans)


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
t = ii()
for _ in range(t):
	x = ii()
	a = ll()
	b = ll()
	one = -1
	minus = -1
	f = 0
	for i in range(x):
		if b[i] > a[i]:
			if one == -1:
				f = 1
				break
		elif b[i] < a[i]:
			if minus == -1:
				f = 1
				break
		if a[i] == 1:
			one = 1
		elif a[i] == -1:
			minus = 1
	if f:
		print('NO')
	else:
		print('YES')


import math
from collections import Counter
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()

def s(a):
	print(' '.join(list(map(str, a))))
t = I()
for i in range(t):
	n = I()
	a = L()
	b = L()
	c = set(a[:n - 1])
	x = 1
	if a[0] != b[0]:
		print('NO')
		continue
	A = 0
	B = 0
	for i in range(1, n):
		if a[i] == b[i]:
			x += 1
	for i in range(n):
		if a[i] == 1 and A == 0:
			A = 1
			for j in range(i + 1, n):
				if a[j] < b[j]:
					x += 1
		elif a[i] == -1 and B == 0:
			B = 1
			for j in range(i + 1, n):
				if a[j] > b[j]:
					x += 1
		if A == 1 and B == 1:
			break
	if x == n:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
	else:
		flag = [False] * 3
		f = True
		for i in range(n):
			if a[i] < b[i]:
				if not flag[2]:
					f = False
					break
			elif a[i] > b[i]:
				if not flag[0]:
					f = False
					break
			flag[a[i] + 1] = True
		print('YES' if f else 'NO')


from sys import *

def func():
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	c = [[0, 0]]
	c1 = 0
	c2 = 0
	for i in range(n):
		if a[i] == 1:
			c1 += 1
		if a[i] == -1:
			c2 += 1
		c.append([c1, c2])
	c1 = True
	for i in range(n - 1, -1, -1):
		if a[i] < b[i] and c[i][0] == 0:
			c1 = False
			break
		if a[i] > b[i] and c[i][1] == 0:
			c1 = False
			break
	print('YES') if c1 == True else print('NO')
t = int(stdin.readline())
while t != 0:
	t -= 1
	func()


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')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	arra = list(map(int, input().split()))
	arrb = list(map(int, input().split()))
	valsbefore = set([])
	checker = True
	for j in range(n):
		if arra[j] != arrb[j]:
			val = arrb[j] - arra[j]
			if val > 0:
				if not 1 in valsbefore:
					checker = False
			elif val < 0:
				if not -1 in valsbefore:
					checker = False
		valsbefore.add(arra[j])
	if checker == False:
		print('NO')
	else:
		print('YES')


case_nums = int(input())
for case_num in range(case_nums):
	length = int(input())
	a = input().split(' ')
	a = [int(i) for i in a]
	b = input().split(' ')
	b = [int(i) for i in b]
	firstPlus1 = -1
	firstMinus1 = -1
	for i in range(length):
		if a[i] == -1:
			firstMinus1 = i
			break
	for i in range(length):
		if a[i] == 1:
			firstPlus1 = i
			break
	ok = True
	for i in range(length):
		j = length - 1 - i
		if a[j] < b[j] and (firstPlus1 >= j or firstPlus1 == -1):
			ok = False
			break
		if a[j] > b[j] and (firstMinus1 >= j or firstMinus1 == -1):
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	n = get_int()
	lst1 = get_int_list()
	lst2 = get_int_list()
	flag = True
	if -1 in lst1:
		neg_1 = lst1.index(-1)
	else:
		neg_1 = None
	if 1 in lst1:
		pos_1 = lst1.index(1)
	else:
		pos_1 = None
	for i in range(n - 1, -1, -1):
		if lst1[i] > lst2[i]:
			if neg_1 is None or neg_1 >= i:
				flag = False
				break
		elif lst1[i] < lst2[i]:
			if pos_1 is None or pos_1 >= i:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


ANS = ''
for i in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	(p, o, ans) = (0, 0, 'YES')
	for i in range(n):
		if a[i] == 1:
			p += 1
		if a[i] == -1:
			o += 1
	for j in range(n):
		i = n - 1 - j
		if a[i] == 1:
			p -= 1
		if a[i] == -1:
			o -= 1
		if b[i] - a[i] > 0:
			if p == 0:
				ans = 'NO'
		if b[i] - a[i] < 0:
			if o == 0:
				ans = 'NO'
	ANS += ans
	ANS += '\n'
print(ANS)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result = 'YES'
	pos1 = 0
	neg1 = 0
	for i in range(n):
		if b[i] != a[i]:
			if b[i] < 0:
				if neg1 == 0:
					result = 'NO'
					break
			elif b[i] > 0:
				if pos1 == 0:
					result = 'NO'
					break
			elif a[i] < 0:
				if pos1 == 0:
					result = 'NO'
					break
			elif neg1 == 0:
				result = 'NO'
				break
		if a[i] > 0:
			pos1 += 1
		elif a[i] < 0:
			neg1 += 1
	print(result)


def analyze(a, b):
	po_i = a.index(1) if 1 in a else len(a)
	mo_i = a.index(-1) if -1 in a else len(a)
	if po_i == mo_i == len(a):
		return b == a
	for index in range(min(mo_i, po_i) + 1):
		if a[index] != b[index]:
			return False
	for index in range(min(mo_i, po_i) + 1, max(mo_i, po_i)):
		if a[min(mo_i, po_i)] > 0 and a[index] > b[index]:
			return False
		if a[min(mo_i, po_i)] < 0 and a[index] < b[index]:
			return False
	if max(mo_i, po_i) == len(a):
		return True
	if a[min(mo_i, po_i)] > 0 and b[max(mo_i, po_i)] < -1:
		return False
	if a[min(mo_i, po_i)] < 0 and b[max(mo_i, po_i)] > 1:
		return False
	return True
for _ in range(int(input())):
	input()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	print({True: 'YES', False: 'NO'}[analyze(a, b)])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(it) for it in input().split()]
	b = [int(ite) for ite in input().split()]
	pos = None
	neg = None
	go = True
	if a[0] == b[0]:
		for i in range(1, n):
			if a[i - 1] < 0:
				neg = True
			elif a[i - 1] > 0:
				pos = True
			if a[i] == b[i]:
				continue
			elif a[i] < b[i]:
				if pos:
					continue
				else:
					print('NO')
					go = False
					break
			elif neg:
				continue
			else:
				print('NO')
				go = False
				break
		if go:
			print('YES')
	else:
		print('NO')


import math

def kind_anton(n, a, b):
	plus = False
	minus = False
	for i in range(0, n):
		if a[i] < b[i] and (not plus):
			print('NO')
			return
		if a[i] > b[i] and (not minus):
			print('NO')
			return
		if a[i] == 1:
			plus = True
		elif a[i] == -1:
			minus = True
	print('YES')
t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	kind_anton(n, a, b)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	k = 0
	a0 = 0
	a1 = 0
	for j in range(n):
		if a[j] == 1:
			a1 += 1
		elif a[j] == -1:
			a0 += 1
		if a[j] != b[j]:
			l = b[j] - a[j]
			c += 1
			if j == 0:
				print('NO')
				b = 1
				break
			elif l > 0 and (a1 > 1 or (a1 == 1 and a[j] != 1)):
				k += 1
				continue
			elif l < 0 and (a0 > 1 or (a0 == 1 and a[j] != -1)):
				k += 1
				continue
			else:
				print('NO')
				b = 1
				break
	if c == k:
		print('YES')
	elif b != 1:
		print('NO')


from sys import stdin
input = 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()]
	was = set()
	for i in range(n):
		if b[i] > a[i] and 1 not in was:
			print('NO')
			break
		elif b[i] < a[i] and -1 not in was:
			print('NO')
			break
		was.add(a[i])
		if 1 in was and -1 in was:
			print('YES')
			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()))
	if a[0] == b[0]:
		met = set()
		met.add(a[0])
		i = 1
		no = False
		while len(met) != 3 and i != n:
			different = b[i] - a[i]
			if different != 0:
				if different // abs(different) in met:
					met.add(a[i])
					i += 1
				else:
					print('NO')
					no = True
					break
			else:
				met.add(a[i])
				i += 1
		if not no:
			if len(met) == 3 or i == n:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for i1 in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if a[0] != b[0]:
		print('NO')
	else:
		neg = -1
		pos = -1
		flag = True
		if a[0] == 1:
			pos = 0
		elif a[0] == -1:
			neg = 0
		for i in range(1, n):
			if a[i] != b[i]:
				if b[i] > a[i] and pos == -1:
					flag = False
					break
				elif b[i] < a[i] and neg == -1:
					flag = False
					break
			if a[i] == 1:
				pos = i
			elif a[i] == -1:
				neg = i
		if flag == True:
			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()))
	inc = n
	dec = n
	for i in range(n):
		if a[i] == -1 and dec == n:
			dec = i
		if a[i] == 1 and inc == n:
			inc = i
	flag = True
	for i in range(n):
		if a[i] < b[i] and i <= inc:
			flag = False
			break
		if a[i] > b[i] and i <= dec:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	L = [False] * 3
	for (a, b) in zip(A, B):
		if a < b:
			if not L[1]:
				break
		elif a > b:
			if not L[-1]:
				break
		L[a] = True
	else:
		print('YES')
		continue
	print('NO')


def fun(n, a, b):
	if a[0] != b[0]:
		print('NO')
		return
	else:
		pre = []
		for i in range(1, n):
			if a[i - 1] not in pre:
				pre.append(a[i - 1])
			if a[i] > b[i]:
				if -1 not in pre:
					print('NO')
					return
			elif a[i] < b[i]:
				if 1 not in pre:
					print('NO')
					return
		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()))
	fun(n, a, b)


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


for _ in range(int(input())):
	(a, b) = [list(map(int, input().split())) for i in '...'][1:]
	s = set()
	for i in range(len(a)):
		if a[i] < b[i] and 1 not in s or (a[i] > b[i] and -1 not in s):
			print('NO')
			break
		s.add(a[i])
		if i == len(a) - 1:
			print('YES')
num_inp = lambda : int(input())
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()


from sys import stdin, stdout
for t in range(int(input())):
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	minus = False
	plus = False
	for i in range(n):
		if a[i] == b[i]:
			pass
		if a[i] > b[i]:
			if minus:
				pass
			else:
				print('NO')
				break
		if a[i] < b[i]:
			if plus:
				pass
			else:
				print('NO')
				break
		if a[i] == 0:
			pass
		if a[i] == -1:
			minus = True
		if a[i] == 1:
			plus = True
	else:
		print('YES')


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


gi = lambda : list(map(int, input().split()))
for _ in range(gi()[0]):
	(n,) = gi()
	a = gi()
	b = gi()
	ans = [0 for __ in range(n)]
	first_one = a.index(1) if 1 in a else n
	first_minus_one = a.index(-1) if -1 in a else n
	for k in range(first_one + 1, n):
		if b[k] >= a[k]:
			ans[k] = 1
	for k in range(first_minus_one + 1, n):
		if b[k] <= a[k]:
			ans[k] = 1
	for k in range(n):
		if a[k] == b[k]:
			ans[k] = 1
	print('NO' if 0 in ans else 'YES')


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt
import math
from itertools import permutations

def main():
	for t in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[0] != b[0]:
			print('NO')
		else:
			ans = 'YES'
			(o, z) = (0, 0)
			for i in a:
				if i == -1:
					z += 1
				elif i == 1:
					o += 1
			for i in range(n - 1, -1, -1):
				if a[i] == 1:
					o -= 1
				elif a[i] == -1:
					z -= 1
				if a[i] > b[i]:
					if z <= 0:
						ans = 'NO'
						break
				elif a[i] < b[i]:
					if o <= 0:
						ans = 'NO'
						break
			print(ans)
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()


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	subpos = [1] * n
	addpos = [1] * n
	i = 0
	while i < n and a[i] != 1:
		addpos[i] = 0
		i += 1
	if i != n:
		addpos[i] = 0
	i = 0
	while i < n and a[i] != -1:
		subpos[i] = 0
		i += 1
	if i != n:
		subpos[i] = 0
	pos = True
	for i in range(n):
		if a[i] > b[i] and subpos[i] == 0:
			pos = False
			break
		if a[i] < b[i] and addpos[i] == 0:
			pos = False
			break
	if pos:
		print('YES')
	else:
		print('NO')
	t -= 1


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		n = int(input())
		aa = [int(a) for a in input().split()]
		bb = [int(a) for a in input().split()]
		pc = 0
		nc = 0
		for j in range(n):
			if bb[j] > aa[j] and pc == 0:
				print('NO')
				return
			if bb[j] < aa[j] and nc == 0:
				print('NO')
				return
			if aa[j] == 1:
				pc += 1
			elif aa[j] == -1:
				nc += 1
		print('YES')
	q = int(input())
	for _ in range(q):
		solve()
main()


from itertools import accumulate
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	codes = {-1: 4, 0: 2, 1: 1}
	a_encoded = [codes[i] for i in a]
	prefix = list(accumulate(a_encoded, lambda i, j: i | j))
	ans = 'YES'
	for i in range(n):
		if b[i] > a[i]:
			if i <= 0 or (i - 1 >= 0 and prefix[i - 1] & 1 == 0):
				ans = 'NO'
				break
		elif b[i] < a[i]:
			if i <= 0 or (i - 1 >= 0 and prefix[i - 1] & 4 == 0):
				ans = 'NO'
				break
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	flag = True
	for i in range(n):
		if a[i] < b[i]:
			if 1 not in s:
				flag = False
		elif a[i] > b[i]:
			if -1 not in s:
				flag = False
		s.add(a[i])
	if flag:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sol = True
	pone = False
	none = False
	for i in range(n):
		if b[i] > a[i] and (not pone):
			sol = False
		if b[i] < a[i] and (not none):
			sol = False
		if a[i] == 1:
			pone = True
		if a[i] == -1:
			none = True
	print('YES' if sol else 'NO')

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


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()))
	seen1 = False
	seenN = False
	works = True
	for i in range(n):
		if l2[i] > l1[i] and (not seen1):
			works = False
			break
		if l2[i] < l1[i] and (not seenN):
			works = False
			break
		if l1[i] == 1:
			seen1 = True
		if l1[i] == -1:
			seenN = True
	if works:
		print('YES')
	else:
		print('NO')


def anton(n, array1, array2):
	one = False
	minusone = False
	if array1[0] != array2[0]:
		return 'NO'
	for i in range(n):
		if one and minusone:
			return 'YES'
		if array2[i] == array1[i]:
			if array1[i] == 1:
				one = True
				continue
			elif array1[i] == 0:
				continue
			else:
				minusone = True
				continue
		elif array1[i] < array2[i]:
			if one:
				if array1[i] == -1:
					minusone = True
				continue
			else:
				return 'NO'
		elif array1[i] > array2[i]:
			if minusone:
				if array1[i] == 1:
					one = True
				continue
			else:
				return 'NO'
	return 'YES'
t = int(input())
array = []
for i in range(t):
	a = int(input())
	l1 = list(map(int, input().split(' ')))
	l2 = list(map(int, input().split(' ')))
	array.append([a, l1, l2])
for f in array:
	print(anton(f[0], f[1], f[2]))


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {-1: 0, 0: 0, 1: 0}
	for v in a:
		d[v] += 1
	f = True
	for i in reversed(range(n)):
		d[a[i]] -= 1
		if a[i] < b[i]:
			if d[1] <= 0:
				f = False
		if a[i] > b[i]:
			if d[-1] <= 0:
				f = False
	if f:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


import sys
input = sys.stdin.readline
a = int(input())
for i in range(a):
	r = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	from collections import defaultdict
	al = defaultdict(int)
	flag = 0
	for i in range(len(x)):
		if x[i] == y[i]:
			al[x[i]] += 1
		elif x[i] - y[i] > 0:
			temp = x[i]
			if al[-1] <= 0:
				flag = 1
				break
			al[temp] += 1
		elif x[i] - y[i] < 0:
			temp = x[i]
			if al[1] <= 0:
				flag = 1
				break
			al[temp] += 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


for ad in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	index = n - 1
	t = 0
	for i in range(n):
		if a[i] != 0:
			index = i
			break
	if a[:index + 1] != b[:index + 1]:
		t = 1
		print('NO')
	else:
		x = -1 * a[index]
		try:
			ind = a.index(x)
		except ValueError:
			ind = n - 1
		if x == -1:
			for i in range(index, ind + 1):
				if b[i] >= a[i]:
					continue
				else:
					t = 1
					print('NO')
					break
		else:
			for i in range(index, ind + 1):
				if a[i] >= b[i]:
					continue
				else:
					t = 1
					print('NO')
					break
		if t == 0:
			print('YES')


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def in_int():
	return int(input())

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

def in_str():
	s = input()
	return list(s[:len(s) - 1])

def in_ints() -> object:
	return map(int, input().split())
t = in_int()
for tt in range(t):
	n = in_int()
	a = in_list()
	b = in_list()
	a1 = [[False, False, False] for i in range(n)]
	a1[0][a[0]] = True
	for i in range(1, len(a)):
		a1[i] = list(a1[i - 1])
		a1[i][a[i]] = True
	ans = True
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(len(a) - 2, -1, -1):
			if b[i + 1] > a[i + 1] and a1[i][1] == False:
				ans = False
			if b[i + 1] < a[i + 1] and a1[i][-1] == False:
				ans = False
		if ans:
			print('YES')
		else:
			print('NO')


t = int(input())
for f in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = 1
	pl = 0
	mi = 0
	for i in range(n):
		if b[i] > a[i] and pl == 0:
			p = 0
			break
		if b[i] < a[i] and mi == 0:
			p = 0
			break
		if a[i] == 1:
			pl = 1
		if a[i] == -1:
			mi = 1
	if p == 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()))
	flag1 = False
	flag2 = False
	ans = False
	for i in range(n):
		if a[i] < b[i]:
			if flag1 == False:
				ans = True
				break
		elif a[i] > b[i]:
			if flag2 == False:
				ans = True
				break
		if a[i] == 1:
			flag1 = True
		elif a[i] == -1:
			flag2 = True
	if ans:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout

def f(a, b, n):
	c = 0
	p = 0
	ne = 0
	if b[0] != a[0]:
		print('NO')
		return
	elif a[0] == 1:
		p = 1
	elif a[0] == -1:
		ne = 1
	for i in range(1, n):
		if p == 0 and a[i - 1] > 0:
			p = 1
		elif ne == 0 and a[i - 1] < 0:
			ne = 1
		if a[i] != b[i]:
			if b[i] > a[i] and p == 0:
				print('NO')
				c = 1
				break
			elif b[i] < a[i] and ne == 0:
				print('NO')
				c = 1
				break
	if c == 0:
		print('YES')
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	f(a, b, n)


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

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

def solve():
	n = read_int()
	a = read_ints()
	b = read_ints()
	counter = {-1: 0, 0: 0, 1: 0}
	for x in a:
		counter[x] += 1
	for i in range(n - 1, -1, -1):
		counter[a[i]] -= 1
		if b[i] == a[i]:
			continue
		elif b[i] > a[i]:
			if counter[1] == 0:
				return 'NO'
		elif counter[-1] == 0:
			return 'NO'
	return 'YES'
T = read_int()
for _ in range(T):
	print(solve())


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = [int(i) for i in sys.stdin.readline().split()]
	b = [int(i) for i in sys.stdin.readline().split()]
	possible = True
	seen_pos = False
	seen_neg = False
	for (i, val) in enumerate(a):
		if val < b[i] and (not seen_pos):
			possible = False
			break
		if val > b[i] and (not seen_neg):
			possible = False
			break
		if val > 0:
			seen_pos = True
		if val < 0:
			seen_neg = True
	if possible:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	ans = True
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	positive = False
	negative = False
	proverka = False
	for k in range(n):
		if a[k] < b[k] and positive == False or (a[k] > b[k] and negative == False):
			print('NO')
			proverka = True
			break
		if a[k] == 1:
			positive = True
		if a[k] == -1:
			negative = True
	if proverka == True:
		continue
	print('YES')


I = input
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	b = list(map(int, I().split()))
	f = 0
	im = next((i for (i, v) in enumerate(a) if v == -1), 10000000000.0)
	ip = next((i for (i, v) in enumerate(a) if v == 1), 10000000000.0)
	for i in range(n):
		d = b[i] - a[i]
		if d < 0 and im >= i or (d > 0 and ip >= i):
			f = 1
			break
	print('NO' if f else 'YES')


import sys
input = sys.stdin.readline

def main():
	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()]
		x = set()
		f = True
		for i in range(N):
			if B[i] > A[i] and 1 not in x:
				print('NO')
				break
			elif B[i] < A[i] and -1 not in x:
				print('NO')
				break
			x.add(A[i])
		else:
			print('YES')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	al = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	ans = ''
	fone = False
	fnegone = False
	pos = 10000000000000000000
	neg = 10000000000000000000
	for i in range(n):
		if al[i] == 1:
			pos = i
			break
	for i in range(n):
		if al[i] == -1:
			neg = i
			break
	for i in range(n - 1, -1, -1):
		if al[i] > bl[i]:
			if neg >= i:
				ans = 'NO'
				break
		if al[i] < bl[i]:
			if pos >= i:
				ans = 'NO'
				break
	if ans == 'NO':
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	(check1, check2) = ([0] * n, [0] * n)
	ans = 1
	for i in range(1, n):
		if check1[i - 1] == 1 or x[i - 1] == 1:
			check1[i] = 1
		if check2[i - 1] == 1 or x[i - 1] == -1:
			check2[i] = 1
	for i in range(n - 1, -1, -1):
		if x[i] < y[i] and check1[i] == 0:
			ans = 0
		if x[i] > y[i] and check2[i] == 0:
			ans = 0
	if ans:
		print('YES')
	else:
		print('NO')


import sys
from queue import LifoQueue
input = sys.stdin.readline

def copy_dict(d):
	x = {}
	for i in d:
		x[i] = d[i]
	return x
t = int(input())
for r in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {1: 0, -1: 0, 0: 0}
	available = [0] * n
	for i in range(n):
		d[a[i]] = 1
		available[i] = copy_dict(d)
	flag = True
	for i in range(n):
		if a[i] != b[i] and i != 0:
			diff = a[i] - b[i]
			check = -1
			if diff < 0:
				check = 1
			if available[i - 1][check] == 0:
				flag = False
				break
		elif a[i] != b[i] and i == 0:
			flag = False
			break
	if flag == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	l = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	r = True
	for j in range(0, l):
		if a[j] != b[j]:
			rr = False
			for i in range(0, j):
				rrr = False
				if (b[j] - a[j]) * a[i] > 0:
					rrr = True
				rr = rr or rrr
				if rr:
					break
			r = rr and r
			if not r:
				break
	if r:
		print('YES')
	else:
		print('NO')


from math import *
for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	z = -1
	o = -1
	m = -1
	for i in range(n):
		if a[i] == 0 and z == -1:
			z = i
		elif a[i] == -1 and m == -1:
			m = i
		elif a[i] == 1 and o == -1:
			o = i
	ans = 'YES'
	for i in range(n):
		if a[i] != b[i]:
			if a[i] < b[i] and (o >= i or o == -1):
				ans = 'NO'
				break
			elif a[i] > b[i] and (m >= i or m == -1):
				ans = 'NO'
				break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = 0
	b = 0
	f = 1
	for i in range(n):
		if l2[i] < l1[i] and a == 0:
			f = 0
			break
		if l2[i] > l1[i] and b == 0:
			f = 0
			break
		if l1[i] == 1:
			b = 1
		if l1[i] == -1:
			a = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


import sys
ans = []
input = sys.stdin.buffer.readline
for j in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ls = list(map(int, input().split()))
	flag_pos = 0
	flag_ne = 0
	flag = 0
	for i in range(n):
		if arr[i] < ls[i]:
			if not flag_pos:
				ans.append('NO')
				flag = 1
				break
		elif arr[i] > ls[i]:
			if not flag_ne:
				ans.append('NO')
				flag = 1
				break
		if arr[i] == 1:
			flag_pos = 1
		if arr[i] == -1:
			flag_ne = 1
	if flag == 0:
		ans.append('YES')
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	arr1 = list(map(int, input().strip().split()))
	arr2 = list(map(int, input().strip().split()))
	if arr1[0] != arr2[0]:
		print('NO')
	else:
		min_sf = [10]
		curr = 2
		for i in range(1, n):
			curr = min(curr, arr1[i - 1])
			min_sf.append(curr)
		max_sf = [10]
		curr = -2
		for i in range(1, n):
			curr = max(curr, arr1[i - 1])
			max_sf.append(curr)
		flg = 0
		for i in range(1, n):
			if arr1[i] != arr2[i]:
				if arr1[i] < arr2[i]:
					if max_sf[i] != 1:
						flg = 1
						break
				elif min_sf[i] != -1:
					flg = 1
					break
		if flg:
			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()))
	if a[0] != b[0]:
		print('NO')
	else:
		has_positive = a[0] > 0
		has_negative = a[0] < 0
		found = True
		for i in range(1, n):
			if b[i] > a[i] and (not has_positive) or (b[i] < a[i] and (not has_negative)):
				found = False
			if a[i] > 0:
				has_positive = True
			if a[i] < 0:
				has_negative = True
			if has_positive and has_negative:
				break
		print('YES' if found else 'NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	barr = list(map(int, input().split()))
	was_minus = False
	was_plus = False
	err = False
	for i in range(n):
		if barr[i] > arr[i] and (not was_plus) or (barr[i] < arr[i] and (not was_minus)):
			err = True
			break
		if arr[i] == 1:
			was_plus = True
		elif arr[i] == -1:
			was_minus = True
	if err:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = True
	un = zun = n - 1
	if a[0] != b[0]:
		p = False
	if p:
		for i in range(n):
			if a[i] == 1:
				un = i
				break
		for j in range(n):
			if a[j] == -1:
				zun = j
				break
		for r in range(un + 1):
			if a[r] < b[r]:
				p = False
				break
		for s in range(zun + 1):
			if a[s] > b[s]:
				p = False
				break
	if p:
		print('YES')
	else:
		print('NO')
	t -= 1


e = int(input())
for ee in range(e):
	n = int(input())
	a = [int(i) for i in input().split(' ', n - 1)]
	b = [int(i) for i in input().split(' ', n - 1)]
	if a[0] != b[0]:
		print('NO')
		continue
	k1 = 0
	k2 = 0
	g = 0
	for i in range(0, n - 1):
		if a[i] == 1:
			k1 += 1
		elif a[i] == -1:
			k2 += 1
	for i in range(n - 1, 0, -1):
		if a[i] > b[i]:
			if k2 == 0:
				g = 1
				break
		elif a[i] < b[i]:
			if k1 == 0:
				g = 1
				break
		if a[i - 1] == 1:
			k1 -= 1
		elif a[i - 1] == -1:
			k2 -= 1
	if g == 1:
		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()))
	state = {0}
	for i in range(n):
		if A[i] == B[i]:
			if A[i] == 1:
				state.add(1)
			elif A[i] == -1:
				state.add(-1)
			continue
		else:
			if A[i] < B[i]:
				if 1 in state:
					if A[i] == -1:
						state.add(-1)
					continue
				else:
					print('NO')
					break
			if A[i] > B[i]:
				if -1 in state:
					if A[i] == 1:
						state.add(1)
					continue
				else:
					print('NO')
					break
	else:
		print('YES')


testcases = int(input())
nList = []
As = []
Bs = []
for i in range(testcases):
	nList.append(int(input()))
	As.append(list(map(int, input().split())))
	Bs.append(list(map(int, input().split())))
for i in range(testcases):
	plusAhead = False
	minusAhead = False
	A = As[i]
	B = Bs[i]
	n = nList[i]
	j = 0
	while j < n:
		if A[j] > B[j] and (not minusAhead):
			break
		elif A[j] < B[j] and (not plusAhead):
			break
		if A[j] == 1:
			plusAhead = True
		elif A[j] == -1:
			minusAhead = True
		j += 1
	if j == n:
		print('YES')
	else:
		print('NO')


t = int(input())
sol = []
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = True
	g = [[0, 0] for i in range(n)]
	nr1 = 0
	nr2 = 0
	for i in range(n):
		if a[i] == 1:
			nr1 += 1
		elif a[i] == -1:
			nr2 += 1
		g[i] = [nr1, nr2]
	if a[0] != b[0]:
		ok = False
	else:
		for i in range(n - 1, 0, -1):
			if b[i] > a[i]:
				if g[i - 1][0] == 0:
					ok = False
					break
			elif b[i] < a[i]:
				if g[i - 1][1] == 0:
					ok = False
					break
	if ok:
		ok = 'YES'
	else:
		ok = 'NO'
	sol.append(ok)
for i in sol:
	print(i)


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


def solve(ans):
	size = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	count = [False] * 3
	count[a[0] + 1] = True
	if b[0] != a[0]:
		ans.append('NO')
		return
	else:
		for i in range(1, size):
			if b[i] != a[i]:
				if b[i] >= 1 and count[2] == False:
					ans.append('NO')
					break
				if b[i] <= -1 and count[0] == False:
					ans.append('NO')
					break
				if b[i] == 0:
					if a[i] == -1 and count[2] == False:
						ans.append('NO')
						break
					elif a[i] == 1 and count[0] == False:
						ans.append('NO')
						break
			if count[2] == False and a[i] == 1:
				count[2] = True
			elif count[0] == False and a[i] == -1:
				count[0] = True
			elif count[1] == False and a[i] == 0:
				count[1] = True
		else:
			ans.append('YES')
	return
n = int(input())
ans = []
for i in range(n):
	solve(ans)
for ele in ans:
	print(ele)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	pos = 0
	neg = 0
	flag = 1
	for i in range(n):
		if l1[i] < l2[i]:
			if pos:
				pass
			else:
				flag = 0
				break
		elif l1[i] > l2[i]:
			if neg:
				pass
			else:
				flag = 0
				break
		if l1[i] > 0:
			pos = 1
		elif l1[i] < 0:
			neg = 1
	if flag:
		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()))
	x = 1
	one = 0
	minus = 0
	for i in range(n - 1):
		if a[i] == 1:
			one += 1
		if a[i] == -1:
			minus += 1
		if a[i + 1] > b[i + 1] and minus == 0:
			x = 0
			break
		if a[i + 1] < b[i + 1] and one == 0:
			x = 0
			break
	if x == 1 and a[0] == b[0]:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	has_neg = False
	has_pos = False
	gg = False
	pos_nums = [0] * len(A)
	neg_nums = [0] * len(A)
	for i in range(1, len(A)):
		pos_nums[i] = pos_nums[i - 1] + (A[i - 1] > 0)
		neg_nums[i] = neg_nums[i - 1] + (A[i - 1] < 0)
	for i in range(len(A) - 1, -1, -1):
		a = A[i]
		b = B[i]
		if a < b and pos_nums[i] == 0:
			gg = True
			break
		if a > b and neg_nums[i] == 0:
			gg = True
			break
	if gg:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	valid = True
	if 1 in a:
		first_1 = a.index(1)
	else:
		first_1 = n
	if -1 in a:
		first_neg_1 = a.index(-1)
	else:
		first_neg_1 = n
	for i in range(n - 1, -1, -1):
		if a[i] > b[i]:
			if first_neg_1 >= i:
				valid = False
				break
		elif a[i] < b[i]:
			if first_1 >= i:
				valid = False
				break
	if valid:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def read():
	x0 = stdin.readline().rstrip()
	return x0

def __main__():
	t = int(read())
	for t0 in range(t):
		n = int(read())
		a = [int(a0) for a0 in read().split()]
		b = [int(b0) for b0 in read().split()]
		if -1 in a:
			mi = a.index(-1)
		else:
			mi = n + 1
		if 1 in a:
			pl = a.index(1)
		else:
			pl = n + 1
		fl = True
		for j in range(n):
			if b[j] > a[j]:
				if pl >= j:
					fl = False
			elif b[j] < a[j]:
				if mi >= j:
					fl = False
		if fl:
			out = 'YES\n'
		else:
			out = 'NO\n'
		stdout.write(out)
__main__()


for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	res = 'YES'
	for i in range(n):
		if b[i] > a[i]:
			if not 1 in d:
				res = 'NO'
				break
		elif b[i] < a[i]:
			if not -1 in d:
				res = 'NO'
				break
		d[a[i]] = 1
	print(res)


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


import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__

def go():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(plus, minus) = (n + 10, n + 10)
	for (i, aa) in enumerate(a):
		if aa > 0:
			plus = min(plus, i)
		if aa < 0:
			minus = min(minus, i)
	for (i, (aa, bb)) in enumerate(zip(a, b)):
		if aa < bb and plus >= i:
			return 'NO'
		if bb < aa and minus >= i:
			return 'NO'
	return 'YES'
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	prefix_1 = [0] * n
	prefix_n1 = [0] * n
	for i in range(n):
		if a[i] == 1:
			prefix_1[i] += 1
		elif a[i] == -1:
			prefix_n1[i] += 1
		prefix_1[i] += prefix_1[i - 1]
		prefix_n1[i] += prefix_n1[i - 1]
	possible = 1
	for i in range(n):
		if i == 0:
			if a[i] != b[i]:
				possible = 0
				break
		elif a[i] > b[i]:
			if prefix_n1[i - 1] <= 0:
				possible = 0
				break
		elif a[i] < b[i]:
			if prefix_1[i - 1] <= 0:
				possible = 0
				break
	if possible:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	d = {}
	d[a[0]] = 1
	flag = 1
	for i in range(1, n):
		diff = b[i] - a[i]
		if diff < 0 and -1 in d:
			d[a[i]] = 1
			continue
		if diff > 0 and 1 in d:
			d[a[i]] = 1
			continue
		if diff == 0:
			d[a[i]] = 1
			continue
		print('NO')
		flag = 0
		break
	if flag == 1:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	a = [int(ele) for ele in input().split()]
	b = [int(ele) for ele in input().split()]
	ind_1 = -1
	ind_minus1 = -1
	for i in range(n):
		if a[i] == 1:
			ind_1 = i
			break
	for i in range(n):
		if a[i] == -1:
			ind_minus1 = i
			break
	flag = 0
	for i in range(n - 1, -1, -1):
		if a[i] != b[i]:
			diff = b[i] - a[i]
			if diff < 0:
				if i == 0:
					flag = 1
					break
				elif ind_minus1 >= i or ind_minus1 == -1:
					flag = 1
					break
			elif i == 0:
				flag = 1
				break
			elif ind_1 >= i or ind_1 == -1:
				flag = 1
				break
			a[i] = b[i]
	if flag == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


import sys
import math as m
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = e = 10000000
	for (i, x) in enumerate(a):
		if x == 1:
			d = min(d, i)
		if x == -1:
			e = min(e, i)
	ans = 'YES'
	for (i, (x, y)) in enumerate(zip(a, b)):
		if y > x and i <= d:
			ans = 'NO'
			break
		if y < x and i <= e:
			ans = 'NO'
			break
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	plus = False
	minus = False
	res = 'YES'
	for i in range(n):
		x = b[i] - a[i]
		if x > 0 and (not plus) or (x < 0 and (not minus)):
			res = 'NO'
			break
		if a[i] == 1:
			plus = True
		elif a[i] == -1:
			minus = True
		if plus and minus:
			break
	print(res)


T = int(input())
output = []
for case in range(1, T + 1):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if 1 in a:
		first_one = a.index(1)
	else:
		first_one = n
	if -1 in a:
		first_neg_one = a.index(-1)
	else:
		first_neg_one = n
	possible = 'YES'
	for i in range(n):
		a_num = a[i]
		b_num = b[i]
		if a_num - b_num < 0:
			if i <= first_one:
				possible = 'NO'
				break
		elif a_num - b_num > 0:
			if i <= first_neg_one:
				possible = 'NO'
				break
	output.append(possible)
for possible in output:
	print(possible)


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

def verify_is_possible(a, b, add):
	if b > a and add < 0:
		return False
	if b < a and add > 0:
		return False
	return True

def test_case():
	n = int(input())
	a = [int(x) for x in input().strip().split(' ')]
	b = [int(x) for x in input().strip().split(' ')]
	if a[0] != b[0]:
		print('NO')
		return
	is_ok = True
	has_a_one = False
	has_a_minus_one = False
	for j in range(1, n):
		if a[j] == b[j]:
			continue
		if b[j] > a[j]:
			if has_a_one:
				continue
			for i in range(0, j):
				if a[i] == 1:
					has_a_one = True
					break
			if has_a_one:
				continue
			else:
				is_ok = False
				break
		else:
			if has_a_minus_one:
				continue
			for i in range(0, j):
				if a[i] == -1:
					has_a_minus_one = True
					break
			if has_a_minus_one:
				continue
			else:
				is_ok = False
				break
		is_ok = False
		break
	if is_ok:
		print('YES')
	else:
		print('NO')

def main():
	t = int(input())
	for x in range(t):
		test_case()
main()


def gcd(a, b):
	if a == -1:
		return b
	elif b == -1:
		return a
	if not a or not b:
		return 0
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().strip().split()))
		b = list(map(int, input().strip().split()))
		if a[0] != b[0]:
			print('NO')
			continue
		(pos, neg) = (-1, -1)
		if a[0] > 0:
			pos = a[0]
		elif a[0] < 0:
			neg = -a[0]
		p = [(pos, neg)]
		for i in range(1, n):
			if a[i] > 0:
				pos = gcd(p[-1][0], a[i])
			elif a[i] < 0:
				neg = gcd(p[-1][1], -a[i])
			p.append((pos, neg))
		flag = False
		for i in range(n - 1, 0, -1):
			diff = b[i] - a[i]
			(pos, neg) = p[i - 1]
			if diff < 0 and neg == -1 or (diff > 0 and pos == -1):
				flag = True
				break
			if diff < 0 and -diff % neg != 0:
				flag = True
				break
			if diff > 0 and diff % pos != 0:
				flag = True
				break
			if b[i] < 0:
				neg = gcd(neg, -b[i])
			elif b[i] > 0:
				pos = gcd(pos, b[i])
		if flag:
			print('NO')
		else:
			print('YES')
main()


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


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	(one, minus_one) = (0, 0)
	flag = 1
	for i in range(n):
		if a[i] < b[i] and (not one):
			flag = 0
		elif a[i] > b[i] and (not minus_one):
			flag = 0
		if a[i] == 1:
			one = 1
		elif a[i] == -1:
			minus_one = 1
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(nf, pf) = (None, None)
	for i in range(n):
		if a[i] > 0 and pf is None:
			pf = i
		elif a[i] < 0 and nf is None:
			nf = i
	done = False
	for j in range(n):
		if b[j] < a[j] and (nf is None or nf >= j):
			print('NO')
			done = True
			break
		if b[j] > a[j] and (pf is None or pf >= j):
			print('NO')
			done = True
			break
	if not done:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(mmin, mmax) = (-1, -1)
	for i in range(n):
		if b[i] < a[i] and mmin == -1:
			mmin = i
		if b[i] > a[i] and mmax == -1:
			mmax = i
	found_mmin = mmin == -1
	found_mmax = mmax == -1
	for i in range(n):
		if a[i] == 1 and i < mmax:
			found_mmax = True
		elif a[i] == -1 and i < mmin:
			found_mmin = True
		if a[i] < b[i] and (not found_mmax) or (a[i] > b[i] and (not found_mmin)):
			break
	if found_mmax and found_mmin:
		print('YES')
	else:
		print('NO')


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
t = inn()
for tt in range(t):
	n = inn()
	a = inl()
	b = inl()
	m = p = n
	for i in range(n):
		if a[i] == -1:
			m = i
			break
	for i in range(n):
		if a[i] == 1:
			p = i
			break
	if m < p:
		ok = True
		for i in range(n):
			if i < m and b[i] != 0 or (i == m and b[i] != -1) or (m < i <= p and b[i] > a[i]):
				ok = False
				break
		print('YES' if ok else 'NO')
	else:
		ok = True
		for i in range(n):
			if i < p and b[i] != 0 or (i == p and b[i] != 1) or (p < i <= m and b[i] < a[i]):
				ok = False
				break
		print('YES' if ok else 'NO')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	helppl = [False] * n
	helpmin = [False] * n
	helppl[0] = a[0] == 1
	helpmin[0] = a[0] == -1
	for i in range(1, n):
		helppl[i] = helppl[i - 1] or a[i] == 1
		helpmin[i] = helpmin[i - 1] or a[i] == -1
	tr = True
	if a[0] != b[0]:
		tr = False
	for i in range(1, n):
		if b[i] - a[i] > 0:
			if not helppl[i - 1]:
				tr = False
		elif b[i] - a[i] < 0:
			if not helpmin[i - 1]:
				tr = False
	if tr:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(t) for t in input().split()]
	b = [int(t) for t in input().split()]
	plus = False
	minus = False
	result = 'YES'
	for i in range(n):
		if plus and minus:
			break
		if a[i] == b[i]:
			if a[i] == 1:
				plus = True
				continue
			elif a[i] == -1:
				minus = True
				continue
		elif a[i] > b[i]:
			if not minus:
				result = 'NO'
				break
			if a[i] == 1:
				plus = True
		else:
			if not plus:
				result = 'NO'
				break
			if a[i] == -1:
				minus = True
	print(result)


Tests = int(input())
for _ in range(Tests):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	possible = 1
	mp = dict()
	for i in range(n):
		if a[i] < b[i]:
			if mp.get(1, None) == None:
				possible = 0
				break
		elif a[i] > b[i]:
			if mp.get(-1, None) == None:
				possible = 0
				break
		mp[a[i]] = 1
	if possible:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = [list(map(int, input().split())) for i in '...'][1:]
	s = set()
	for i in range(len(a)):
		if a[i] < b[i] and 1 not in s or (a[i] > b[i] and -1 not in s):
			print('NO')
			break
		s.add(a[i])
		if i == len(a) - 1:
			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()]
	positive = False
	negative = False
	possible = True
	for (ai, bi) in zip(a, b):
		if bi > ai and (not positive):
			possible = False
			break
		if bi < ai and (not negative):
			possible = False
			break
		if ai > 0:
			positive = True
		if ai < 0:
			negative = True
	if possible:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
from collections import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	flag = True
	for (ai, bi) in zip(a, b):
		if ai < bi:
			if 1 not in s:
				flag = False
		elif ai > bi:
			if -1 not in s:
				flag = False
		s.add(ai)
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin
for __ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	x = a.count(1)
	y = a.count(-1)
	ans = True
	for i in range(n - 1, -1, -1):
		if a[i] == 1:
			x -= 1
		elif a[i] == -1:
			y -= 1
		if b[i] > a[i] and (not x):
			ans = False
			break
		if b[i] < a[i] and (not y):
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	k = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	d = 0
	e = 'YES'
	for i in range(len(a)):
		if a[i] < b[i] and c == 0:
			e = 'NO'
			break
		elif a[i] > b[i] and d == 0:
			e = 'NO'
			break
		elif a[i] == 1:
			c = 1
		elif a[i] == -1:
			d = 1
	print(e)


kl = int(input())
for l in range(kl):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	(pr, m, p) = (0, 0, 0)
	for i in range(n):
		if b[i] == a[i] or (b[i] < a[i] and m == 1) or (b[i] > a[i] and p == 1):
			pr = 0
		else:
			pr = 1
			break
		if a[i] == -1:
			m = 1
		if a[i] == 1:
			p = 1
	if pr:
		print('NO')
	else:
		print('YES')


def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	good = [0, 0]
	for i in range(n):
		if a[i] > b[i] and (not good[0]):
			print('NO')
			return
		elif a[i] < b[i] and (not good[1]):
			print('NO')
			return
		if a[i] == -1:
			good[0] = 1
		if a[i] == 1:
			good[1] = 1
	print('YES')
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	d = {}
	d[1] = 0
	d[-1] = 0
	for i in range(n):
		if ar[i] == 1 or ar[i] == -1:
			d[ar[i]] = d.get(ar[i]) + 1
	fl = False
	for i in range(n - 1, -1, -1):
		if ar[i] == -1 or ar[i] == 1:
			d[ar[i]] = d.get(ar[i]) - 1
		if ar[i] != br[i]:
			t = br[i] - ar[i]
			if t < 0:
				if d.get(-1) == 0:
					fl = True
			elif t > 0:
				if d.get(1) == 0:
					fl = True
	if fl:
		print('NO')
	else:
		print('YES')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {1: 0, -1: 0}
	k = 1
	for i in range(n):
		if a[i] == 1:
			d[1] += 1
		elif a[i] == -1:
			d[-1] += 1
	for i in range(n - 1, -1, -1):
		if a[i] > b[i]:
			if a[i]:
				d[a[i]] -= 1
			if d[-1] <= 0:
				print('NO')
				k = 0
				break
		elif a[i] < b[i]:
			if a[i]:
				d[a[i]] -= 1
			if d[1] <= 0:
				print('NO')
				k = 0
				break
		elif a[i] == b[i]:
			if a[i]:
				d[a[i]] -= 1
	if k:
		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()))
	if a[0] != b[0]:
		print('NO')
		continue
	s = set()
	s.add(a[0])
	x = 0
	for i in range(1, n):
		if a[i] != b[i]:
			if (b[i] - a[i]) // abs(b[i] - a[i]) not in s:
				print('NO')
				x = 1
				break
			if (b[i] - a[i]) // abs(b[i] - a[i]) in s:
				s.add(a[i])
		if a[i] == b[i]:
			s.add(a[i])
	if x == 0:
		print('YES')


def artem(n, m):
	if m * n % 2 == 1:
		return ('BW' * (m // 2) + 'B\n' + 'WB' * (m // 2) + 'W\n') * (n // 2) + 'BW' * (m // 2) + 'B\n'
	else:
		return ('BW' * ((m - 1) // 2) + 'B\n' * (m % 2) + 'BW\n' * ((m - 1) % 2) + 'WB' * ((m - 1) // 2) + 'W\n' * (m % 2) + 'WB\n' * ((m - 1) % 2)) * ((n - 1) // 2) + 'BW' * ((m - 1) // 2) + 'BB\n' * ((m - 1) % 2) + 'B\n' * (m % 2) + ('WB' * ((m - 1) // 2) + 'B\n' * (m % 2) + 'WB\n' * ((m - 1) % 2)) * ((n - 1) % 2)

def anton(a, b):
	found = [False, False]
	for i in range(len(a)):
		if found[0] and found[1]:
			return 'YES'
		if a[i] == 1 and (not found[1]):
			found[1] = True
			if a[i] < b[i]:
				return 'NO'
		if a[i] == -1 and (not found[0]):
			found[0] = True
			if a[i] > b[i]:
				return 'NO'
		if a[i] > b[i] and (not found[0]):
			return 'NO'
		if a[i] < b[i] and (not found[1]):
			return 'NO'
	return 'YES'
cases = int(input())
for _ in range(cases):
	l = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(anton(a, b))


from collections import defaultdict as dd
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	diff = [0] * (n + 1)
	contain = [0] * (n + 1)
	contain[0] = dd(int)
	for i in range(1, len(a)):
		dic = contain[i - 1].copy()
		dic[a[i - 1]] = 1
		contain[i] = dic
	k = True
	for i in range(len(a)):
		diff[i] = b[i] - a[i]
	if diff[0] != 0:
		print('NO')
	else:
		for i in range(1, len(diff)):
			if diff[i] > 0 and contain[i][1] != 1:
				k = False
				break
			elif diff[i] < 0 and contain[i][-1] != 1:
				k = False
				break
		if k:
			print('YES')
		else:
			print('NO')


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
res = ['YES', 'NO']
for _ in range(ii()):
	n = ii()
	a = li()
	b = li()
	s = {0}
	f = 0
	for i in range(n):
		if 1 in s and -1 in s:
			break
		if a[i] < b[i]:
			if 1 not in s:
				f = 1
				break
		elif a[i] > b[i]:
			if -1 not in s:
				f = 1
				break
		s.add(a[i])
	print(res[f])


import sys
readLine = lambda : sys.stdin.readline()
readInt = lambda : int(sys.stdin.readline())
readInts = lambda : [int(x) for x in sys.stdin.readline().split(' ')]

def main():
	t = readInt()
	solns = []
	for _ in range(t):
		n = readInt()
		a = readInts()
		b = readInts()
		canIncrement = False
		canDecrement = False
		valid = False
		for (i, x) in enumerate(b):
			if canIncrement and canDecrement:
				valid = True
				break
			if a[i] == x:
				if a[i] < 0:
					canDecrement = True
				elif a[i] > 0:
					canIncrement = True
				continue
			elif a[i] < x:
				if not canIncrement:
					break
				if a[i] < 0:
					canDecrement = True
			else:
				if not canDecrement:
					break
				if a[i] > 0:
					canIncrement = True
		else:
			valid = True
		s = 'YES' if valid else 'NO'
		solns.append(s)
	print('\n'.join(solns))
main()


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(' ')]
	non_zero = -1
	for i in range(n):
		if a[i] != 0 or b[i] != 0:
			non_zero = i
			break
	no = False
	one = False
	minus_one = False
	first = True
	for i in range(non_zero, n):
		if first:
			if a[i] == b[i]:
				if a[i] == 1:
					one = True
				else:
					minus_one = True
				first = False
			else:
				no = True
				break
		elif one and (not minus_one):
			if a[i] > b[i]:
				no = True
				break
			else:
				minus_one = a[i] == -1
		elif minus_one and (not one):
			if a[i] < b[i]:
				no = True
				break
			else:
				one = a[i] == 1
		else:
			break
	print('NO' if no else 'YES')


cases = int(input())
ans = 0
for x in range(cases):
	length = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	w = set([])
	for i in range(length):
		if a[i] < b[i] and (not 1 in w):
			print('NO')
			break
		elif a[i] > b[i] and (not -1 in w):
			print('NO')
			break
		w.add(a[i])
	else:
		print('YES')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		return
	(pos, neg) = (0, 0)
	if a[0] > 0:
		pos = 1
	elif a[0] < 0:
		neg = 1
	for i in range(1, n):
		if b[i] < a[i]:
			if not neg:
				print('NO')
				return
		elif b[i] > a[i]:
			if not pos:
				print('NO')
				return
		if a[i] > 0:
			pos = 1
		elif a[i] < 0:
			neg = 1
	print('YES')
for _ in range(int(input())):
	main()


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


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def main():
	T = int(rl())
	for _ in range(T):
		n = int(rl())
		A = [int(x) for x in rll()]
		B = [int(x) for x in rll()]
		(seen_pos, seen_neg) = (0, 0)
		ans = True
		for (i, (a, b)) in enumerate(zip(A, B)):
			if i == 0 and a != b:
				ans = False
				break
			if b > a and (not seen_pos):
				ans = False
				break
			if b < a and (not seen_neg):
				ans = False
				break
			if a < 0:
				seen_neg = 1
			if a > 0:
				seen_pos = 1
		if ans:
			stdout.write('YES')
			stdout.write('\n')
		else:
			stdout.write('NO')
			stdout.write('\n')
	stdout.close()
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(map(int, input().split()))
	temp = []
	flag = 0
	for i in range(len(s)):
		if l[i] != s[i]:
			d = s[i] - l[i]
			if d < 0:
				if -1 not in temp:
					flag = 1
					break
			if d > 0:
				if 1 not in temp:
					flag = 1
					break
			if l[i] not in temp:
				temp.append(l[i])
		elif l[i] not in temp:
			temp.append(l[i])
	if flag == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
for i in range(t):
	p = 0
	m = 0
	flag = 0
	n = int(input())
	ls1 = list(map(int, input().split()))
	ls2 = list(map(int, input().split()))
	for j in range(n):
		if ls1[j] == ls2[j]:
			if ls1[j] == 1:
				p = 1
			elif ls1[j] == -1:
				m = 1
		if ls2[j] > 0 and p != 1:
			ans.append('NO')
			flag = 1
			break
		elif ls2[j] < 0 and m != 1:
			ans.append('NO')
			flag = 1
			break
		elif ls2[j] == 0:
			if ls1[j] == 1 and m != 1:
				ans.append('NO')
				flag = 1
				break
			elif ls1[j] == -1 and p != 1:
				ans.append('NO')
				flag = 1
				break
		if ls1[j] == 1:
			p = 1
		elif ls1[j] == -1:
			m = 1
	if flag == 0:
		ans.append('YES')
for k in range(t):
	print(ans[k])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = True
	s = set()
	for i in range(n):
		if a[i] == b[i] or (b[i] > a[i] and 1 in s) or (b[i] < a[i] and -1 in s):
			s.add(a[i])
			continue
		else:
			pos = False
			break
	print('YES' if pos else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = True
	ed = med = -2
	if 1 in a:
		ed = a.index(1)
	if -1 in a:
		med = a.index(-1)
	ed += 1
	med += 1
	for i in range(n - 1, -1, -1):
		if a[i] < b[i]:
			if ed == -1 or i < ed:
				flag = False
				break
		elif a[i] > b[i]:
			if med == -1 or i < med:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = 0
	c = set()
	c.add(0)
	for i in range(n):
		if len(c) == 3:
			break
		if a[i] == b[i]:
			c.add(a[i])
		elif a[i] < b[i]:
			p = 1
			if p in c:
				c.add(a[i])
				continue
			else:
				l += 1
				break
		elif a[i] > b[i]:
			p = -1
			if p in c:
				c.add(a[i])
				continue
			else:
				l += 1
				break
	if l == 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()))
	c = []
	o = z = 0
	for i in a:
		if i == -1:
			z += 1
		elif i == 1:
			o += 1
		c.append([o, z])
	fl = 0
	for i in range(n - 1, 0, -1):
		if b[i] > a[i]:
			if c[i - 1][0] < 1:
				fl = 1
		elif b[i] < a[i]:
			if c[i - 1][1] < 1:
				fl = 1
	if a[0] != b[0]:
		fl = 1
	if fl:
		print('NO')
	else:
		print('YES')


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	n = read_int()
	a = read_int_line()
	b = read_int_line()
	c = [0] * n
	for i in range(n):
		c[i] = b[i] - a[i]
	d = {}
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = i
		else:
			continue
	if -1 not in d:
		d[-1] = 1000000000.0
	if 1 not in d:
		d[1] = 1000000000.0
	if 0 not in d:
		d[0] = 1000000000.0
	f = True
	for i in range(n):
		if c[i] == 0:
			continue
		elif c[i] > 0:
			if d[1] >= i:
				f = False
		elif c[i] < 0:
			if d[-1] >= i:
				f = False
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	alis = list(map(int, input().split()))
	blis = list(map(int, input().split()))
	plus = False
	minus = False
	pos = True
	for j in range(n):
		if plus and minus:
			continue
		if plus:
			if alis[j] == -1:
				minus = True
			if blis[j] < alis[j]:
				pos = False
		elif minus:
			if alis[j] == 1:
				plus = True
			if blis[j] > alis[j]:
				pos = False
		else:
			if alis[j] == 1:
				plus = True
			if alis[j] == -1:
				minus = True
			if blis[j] != alis[j]:
				pos = False
	if pos:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	f = 0
	(pos, neg) = (0, 0)
	if a[0] != b[0]:
		print('NO')
		continue
	for i in range(1, n):
		if a[i - 1] == 1:
			pos = 1
		elif a[i - 1] == -1:
			neg = 1
		if a[i] == b[i]:
			continue
		elif b[i] - a[i] > 0 and pos:
			continue
		elif b[i] - a[i] < 0 and neg:
			continue
		else:
			f = 1
			break
	if f:
		print('NO')
	else:
		print('YES')


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
import bisect
for _ in range(q):
	n = int(input())
	data = list(map(int, input().split()))
	datb = list(map(int, input().split()))
	datc = []
	indmin = []
	indplus = []
	for i in range(n):
		if data[i] == 1:
			indplus.append(i)
		elif data[i] == -1:
			indmin.append(i)
	f = True
	for i in range(n - 1, -1, -1):
		d = datb[i] - data[i]
		if d == 0:
			continue
		elif d > 0:
			ind = bisect.bisect_left(indplus, i)
			if ind == 0:
				f = False
		elif d < 0:
			ind = bisect.bisect_left(indmin, i)
			if ind == 0:
				f = False
	print('YES' if f else 'NO')


def answer(n, a, b):
	s = set()
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] > b[i] and -1 in s:
			pass
		elif a[i] < b[i] and 1 in s:
			pass
		else:
			return 'NO'
		s.add(a[i])
	return 'YES'

def main():
	t = int(input())
	n = [0] * t
	a = [0] * t
	b = [0] * t
	for j in range(t):
		n[j] = int(input())
		a[j] = [int(i) for i in input().split()]
		b[j] = [int(i) for i in input().split()]
	for j in range(t):
		print(answer(n[j], a[j], b[j]))
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	seen = set()
	for i in range(n):
		if a[i] > b[i]:
			if -1 not in seen:
				print('NO')
				break
		elif a[i] < b[i]:
			if 1 not in seen:
				print('NO')
				break
		seen.add(a[i])
	else:
		print('YES')


def solve(a, b, n):
	if a == b:
		return 'YES'
	elif abs(b[0] - a[0]) != 0:
		return 'NO'
	else:
		s = set()
		s.add(a[0])
		for i in range(1, n):
			if b[i] - a[i] != 0 and int((b[i] - a[i]) / abs(b[i] - a[i])) not in s:
				return 'NO'
			s.add(a[i])
		return 'YES'
t = int(input())
ans = []
for s in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ans.append(solve(a, b, n))
for it in ans:
	print(it)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	u = False
	d = False
	now_res = True
	for j in range(n):
		if a[j] > b[j]:
			if not d:
				now_res = False
				break
		elif a[j] < b[j]:
			if not u:
				now_res = False
				break
		if a[j] == -1:
			d = True
		if a[j] == 1:
			u = True
	if now_res:
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


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


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	answer = 'YES'
	hasMinus = False
	hasPlus = False
	for i in range(n):
		if a[i] != b[i]:
			if a[i] < b[i] and (not hasPlus):
				answer = 'NO'
			elif a[i] > b[i] and (not hasMinus):
				answer = 'NO'
			if answer == 'NO':
				break
		if a[i] == -1:
			hasMinus = True
		elif a[i] == 1:
			hasPlus = True
	print(answer)


from sys import stdin, stdout
from collections import *
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	n = inp()
	a = li()
	b = li()
	(one, zero, ne_one) = ([], [], [])
	for i in range(n):
		if a[i] == 0:
			zero.append(i)
		elif a[i] == -1:
			ne_one.append(i)
		else:
			one.append(i)
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		if a[i] < b[i]:
			if one:
				if one[0] >= i:
					pr('NO')
					return
			else:
				pr('NO')
				return
		elif ne_one:
			if ne_one[0] >= i:
				pr('NO')
				return
		else:
			pr('NO')
			return
	pr('YES')
for _ in range(inp()):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [0] * n
	e = 0
	f = 0
	for i in range(1, n):
		if a[i - 1] == 1:
			e = 1
		if a[i - 1] == -1:
			f = 2
		c[i] = e + f
	d = [0] * n
	for i in range(n):
		if b[i] > a[i]:
			d[i] = 1
		if b[i] < a[i]:
			d[i] = -1
	g = 0
	for i in range(n):
		if d[i] == 1:
			if c[i] == 1 or c[i] == 3:
				g = 0
			else:
				g = 1
				break
		if d[i] == -1:
			if c[i] == 2 or c[i] == 3:
				g = 0
			else:
				g = 1
				break
	if g == 0:
		print('YES')
	else:
		print('NO')


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p1 = n - 1
	p2 = n - 1
	for i in range(n):
		if a[i] > 0 and p1 >= n - 1:
			p1 = i
		if a[i] < 0 and p2 >= n - 1:
			p2 = i
	ok = 1
	for i in range(min(p1, p2) + 1):
		if a[i] != b[i]:
			ok = 0
	for i in range(min(p1, p2) + 1, max(p1, p2) + 1):
		if p1 < p2:
			if a[i] > b[i]:
				ok = 0
		elif b[i] > a[i]:
			ok = 0
	print('YES' if ok else 'NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		lst1 = list(map(int, input().split()))
		lst2 = list(map(int, input().split()))
		(p, m) = (False, False)
		if lst1[0] != lst2[0]:
			yield 'NO'
		else:
			if n == 1:
				yield 'YES'
			for i in range(1, n):
				ele = lst1[i - 1]
				if ele > 0:
					p = True
				elif ele < 0:
					m = True
				if lst2[i] > lst1[i] and (not p):
					yield 'NO'
					break
				elif lst2[i] < lst1[i] and (not m):
					yield 'NO'
					break
				if i == n - 1:
					yield 'YES'
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
from copy import deepcopy
for t in range(int(sys.stdin.readline().strip())):
	n = int(sys.stdin.readline().strip())
	a = [int(j) for j in sys.stdin.readline().split()]
	b = [int(j) for j in sys.stdin.readline().split()]
	f1 = False
	f2 = False
	ls = []
	ms = []
	for i in range(n):
		ls.append(f1)
		ms.append(f2)
		if a[i] == -1:
			f2 = True
		if a[i] == 1:
			f1 = True
	for i in range(n):
		diff = b[i] - a[i]
		if diff > 0 and ls[i] == False:
			print('NO')
			break
		if diff < 0 and ms[i] == False:
			print('NO')
			break
	else:
		print('YES')


def canForm(a, b):
	elementsSoFar = set()
	for i in range(len(a)):
		if a[i] == b[i]:
			pass
		elif a[i] < b[i]:
			if not 1 in elementsSoFar:
				return False
		elif not -1 in elementsSoFar:
			return False
		elementsSoFar.add(a[i])
	return True

def getTestCases():
	numTestCases = int(input())
	testCases = [0] * numTestCases
	for i in range(numTestCases):
		arrSize = int(input())
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		testCases[i] = (a, b)
	return testCases
testCases = getTestCases()
for testCase in testCases:
	if canForm(testCase[0], testCase[1]):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	c = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	pl = -1
	mi = -1
	f = True
	for i in range(c):
		if a[i] > b[i] and mi == -1 or (a[i] < b[i] and pl == -1):
			f = False
			break
		if a[i] > 0:
			pl = i
		elif a[i] < 0:
			mi = i
	if f:
		print('YES')
	else:
		print('NO')


from sys import exit

def i():
	return input()

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

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

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

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	n = ii()
	a = liis()
	b = liis()
	can = True
	options = set()
	for i in range(n):
		if b[i] == a[i]:
			options.add(a[i])
			continue
		elif b[i] < a[i]:
			if -1 not in options:
				can = False
				break
		elif 1 not in options:
			can = False
			break
		options.add(a[i])
	if can:
		print('YES')
	else:
		print('NO')


def poss(n, a, b):
	o = 0
	if a == b:
		return True
	if a.count(0) == n:
		return False
	while a[o] == 0 and b[o] == 0:
		o += 1
	p1 = 0
	n1 = 0
	f = 0
	if a[o] != b[o]:
		return False
	if a.count(1) == 0:
		for i in range(0, len(b)):
			if a[i] < b[i]:
				return False
		p1 = n - 1
		f = 1
	if a.count(-1) == 0:
		for i in range(0, len(b)):
			if a[i] > b[i]:
				return False
		n1 = n - 1
		f = 1
	if f == 0:
		p1 = a.index(1)
		n1 = a.index(-1)
	if n1 < p1:
		for i in range(n1 + 1, p1 + 1):
			if i == p1:
				if b[i] > 1:
					return False
			elif b[i] > a[i]:
				return False
	else:
		for i in range(p1 + 1, n1 + 1):
			if i == n1:
				if b[i] < -1:
					return False
			elif b[i] < a[i]:
				return False
	return True
t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if poss(n, a, b):
		print('YES')
	else:
		print('NO')


from math import *
mod = 1000000007
for zz in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ha = True
	hp = False
	hm = False
	for i in range(n):
		if b[i] != a[i]:
			if b[i] > a[i]:
				if hp:
					pass
				else:
					ha = False
					break
			elif hm:
				pass
			else:
				ha = False
				break
		if a[i] > 0:
			hp = True
		elif a[i] < 0:
			hm = True
	if ha:
		print('YES')
	else:
		print('NO')


def sign(n):
	if n == 0:
		return 0
	else:
		return n // abs(n)

def solve():
	n = int(input())
	array1 = [int(x) for x in input().split()]
	array2 = [int(x) for x in input().split()]
	f_neg = n
	f_pos = n
	comparisons = []
	for i in range(n):
		if array1[i] > 0 and f_pos == n:
			f_pos = i
		if array1[i] < 0 and f_neg == n:
			f_neg = i
		cur_sign = sign(array2[i] - array1[i])
		if cur_sign > 0 and f_pos >= i:
			return 'NO'
		elif cur_sign < 0 and f_neg >= i:
			return 'NO'
	return 'YES'
t = int(input())
for case in range(t):
	print(solve())


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(' ')]
	i_p = n
	i_m = n
	i = 0
	while i < len(a) and (i_p == n or i_m == n):
		if i_m == n and a[i] == -1:
			i_m = i
		elif i_p == n and a[i] == 1:
			i_p = i
		i += 1
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		if a[i] > b[i] and i_m < i:
			continue
		if a[i] < b[i] and i_p < i:
			continue
		else:
			break
	if i == 0 and a[0] == b[0]:
		print('YES')
	else:
		print('NO')


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	r = False
	if a[0] != b[0]:
		print('NO')
		r = True
	else:
		s = set()
		s.add(a[0])
		for x in range(1, n):
			if b[x] > a[x] and 1 not in s:
				r = True
				break
			if b[x] < a[x] and -1 not in s:
				r = True
				break
			s.add(a[x])
		if r == True:
			print('NO')
		else:
			print('YES')
	i = i + 1


import sys
input = sys.stdin.readline

def main():
	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()]
		(p, m) = (0, 0)
		ok = 1
		for i in range(n):
			if a[i] < b[i]:
				if not p:
					ok = 0
			if a[i] > b[i]:
				if not m:
					ok = 0
			if a[i] == 1:
				p = 1
			if a[i] == -1:
				m = 1
		print('YES' if ok else 'NO')
main()


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = list(map(int, input().split()))
	f = 0
	(x, y) = (n + 1, n + 1)
	for i in range(n):
		if l[i] == 1:
			x = i
			break
	for i in range(n):
		if l[i] == -1:
			y = i
			break
	if l[0] == d[0]:
		for i in range(1, n):
			if l[i] == d[i]:
				continue
			elif l[i] < d[i]:
				if x < i:
					continue
				else:
					f = 1
					break
			elif l[i] > d[i]:
				if y < i:
					continue
				else:
					f = 1
					break
		if f == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	a = li()
	b = li()
	(m, z, o) = (n, n, n)
	f = 1
	for i in range(n):
		if a[i] == -1 and m == n:
			m = i
		if a[i] == 0 and z == n:
			z = i
		if a[i] == 1 and o == n:
			o = i
	for i in range(n):
		if a[i] == b[i]:
			continue
		elif a[i] > b[i] and m >= i:
			f = 0
			break
		elif a[i] < b[i] and o >= i:
			f = 0
			break
	if f:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	case()


t = int(input())
for tt in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	foundpos = 0
	foundneg = 0
	ans = True
	for i in range(n):
		if b[i] > a[i] and (not foundpos):
			ans = False
		if b[i] < a[i] and (not foundneg):
			ans = False
		if a[i] == -1:
			foundneg = True
		if a[i] == 1:
			foundpos = True
	print('YES' if ans else 'NO')


for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	(inc, dec, brk) = (False, False, False)
	for i in range(n):
		if a[i] < b[i] and (not inc) or (a[i] > b[i] and (not dec)):
			brk = True
			break
		inc = inc or a[i] == 1
		dec = dec or a[i] == -1
	print(['YES', 'NO'][brk])


t = int(input())

def solve(n, a, b):
	d = [0] * n
	for i in range(n):
		d[i] = b[i] - a[i]
	divs = {}
	prev = {}
	for i in range(n):
		if a[i] not in divs.keys():
			divs[a[i]] = True
			prev[a[i]] = i
	res = True
	for (i, dif) in enumerate(d):
		if dif > 0 and (1 not in divs.keys() or prev[1] >= i):
			res = False
			break
		if dif < 0 and (-1 not in divs.keys() or prev[-1] >= i):
			res = False
			break
	if res:
		print('YES')
	else:
		print('NO')
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, a, b)


def Solve():
	for t in range(int(input())):
		list_ = [0]
		n = int(input())
		a = input().split()
		b = input().split()
		e = True
		index_ = n
		if '1' in a and '-1' in a:
			index_ = max(a.index('1'), a.index('-1'))
		for (x, y) in zip(a[:index_ + 1], b[:index_ + 1]):
			x = int(x)
			y = int(y)
			if x != y:
				if x < y:
					if 1 not in list_:
						e = False
						break
				elif x > y:
					if -1 not in list_:
						e = False
						break
			list_.append(x)
		if e:
			print('YES')
		else:
			print('NO')
Solve()


import math
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	N = int(input())
	A = alele()
	B = alele()
	flag = 0
	if A[0] != B[0]:
		print('NO')
	else:
		pos = 0
		neg = 0
		for i in range(N):
			if B[i] > A[i] and pos == 0:
				flag = 1
				break
			elif B[i] < A[i] and neg == 0:
				flag = 1
				break
			if A[i] > 0:
				pos = 1
			elif A[i] < 0:
				neg = 1
		if flag == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for k in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = 0
	res = []
	for i in range(n):
		if l1[i] not in res:
			if l1[i] == l2[i]:
				a = a + 0
			elif l1[i] < l2[i]:
				if 1 not in res:
					a = a + 1
			elif l2[i] < l1[i]:
				if -1 not in res:
					a = a + 1
			res.append(l1[i])
		elif l1[i] == l2[i]:
			a = a + 0
		elif l1[i] < l2[i]:
			if 1 not in res:
				a = a + 1
		elif l2[i] < l1[i]:
			if -1 not in res:
				a = a + 1
	if a == 0:
		print('YES')
	elif a > 0:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = []
	b = []
	neg = 0
	pos = 0
	flag = 0
	x = input().split()
	y = input().split()
	for i in range(n):
		a.append(int(x[i]))
		b.append(int(y[i]))
	for i in range(n):
		if a[i] > b[i]:
			if neg == 1:
				if pos == 0 and a[i] == 1:
					pos = 1
			else:
				flag = 1
				break
		elif a[i] < b[i]:
			if pos == 1:
				if neg == 0 and a[i] == -1:
					neg = 1
			else:
				flag = 1
				break
		elif a[i] == 1:
			pos = 1
		elif a[i] == -1:
			neg = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


from math import ceil
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	p1 = 0
	p2 = 0
	while p1 < n - 1 and a[p1] != 1:
		p1 += 1
	while p2 < n - 1 and a[p2] != -1:
		p2 += 1
	f = 'YES'
	for i in range(p1 + 1):
		if b[i] > a[i]:
			f = 'NO'
	for i in range(p2 + 1):
		if b[i] < a[i]:
			f = 'NO'
	print(f)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():

	def ok():
		p = m = False
		for (a, b) in zip(aa, bb):
			if a < b and (not p):
				return False
			if a > b and (not m):
				return False
			if a == 1:
				p = True
			if a == -1:
				m = True
		return True
	for _ in range(II()):
		n = II()
		aa = LI()
		bb = LI()
		if ok():
			print('YES')
		else:
			print('NO')
main()


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def solve(n):
	return n * (n + 1) // 2
ans = []
t = int(input())
for _ in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	(a, b) = (l1[0], l2[0])
	if a == b:
		seti = set()
		flag = 0
		for i in range(n):
			if l1[i] == l2[i]:
				seti.add(l1[i])
			else:
				if l1[i] > l2[i]:
					if -1 in seti:
						seti.add(l1[i])
						continue
					else:
						flag = 1
						break
				if l1[i] < l2[i]:
					if 1 in seti:
						seti.add(l1[i])
						continue
					else:
						flag = 1
						break
		if not flag:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


R = lambda : map(int, input().split())
t = int(input())

def sign(n):
	if n > 0:
		return 1
	if n < 0:
		return -1
	if n == 0:
		return 0

def solve(a, b, n):
	ar = [False] * 3
	ar[0] = True
	for i in range(n):
		temp = b[i] - a[i]
		if not ar[sign(temp)]:
			return 'NO'
		ar[sign(a[i])] = True
	return 'YES'
for _ in range(t):
	n = int(input())
	a = list(R())
	b = list(R())
	print(solve(a, b, n))


import sys
input = sys.stdin.readline
print = sys.stdout.write
for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	stat = True
	(stat1, stat2) = (0, 0)
	for i in b:
		if i == 1:
			stat1 += 1
		elif i == -1:
			stat2 += 1
	for i in range(a):
		now = b.pop()
		now2 = c.pop()
		if now == 1:
			stat1 -= 1
		if now == -1:
			stat2 -= 1
		if now == now2:
			continue
		elif now > now2:
			if stat2:
				continue
			else:
				stat = False
				break
		elif now2 > now:
			if stat1:
				continue
			else:
				stat = False
				break
	print('YES\n' if stat else 'NO\n')


m = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(N, a, b, p, n, v) = (int(input()), m(), m(), 0, 0, 'NO')
	for i in range(N):
		if b[i] > a[i] and 1 - p or (b[i] < a[i] and 1 - n):
			break
		if a[i] == 1:
			p = 1
		if a[i] == -1:
			n = 1
		if p and n or i == N - 1:
			v = 'YES'
			break
	print(v)


t = int(input())
for q in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k0 = 0
	k1 = 0
	k2 = 0
	e = 1
	for i in range(0, n):
		if a[i] == 0:
			if a[i] == b[i]:
				k1 = 1
			elif a[i] > b[i] and k0 == 1:
				k1 = 1
			elif a[i] < b[i] and k2 == 1:
				k1 = 1
			else:
				e = 0
				break
		elif a[i] == 1:
			if a[i] == b[i]:
				k2 = 1
			elif a[i] > b[i] and k0 == 1:
				k2 = 1
			elif a[i] < b[i] and k2 == 1:
				k2 = 1
			else:
				e = 0
				break
		elif a[i] == b[i]:
			k0 = 1
		elif a[i] > b[i] and k0 == 1:
			k0 = 1
		elif a[i] < b[i] and k2 == 1:
			k0 = 1
		else:
			e = 0
			break
	if e == 0:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.buffer.readline

def array_to_string(a):
	s = ''
	for i in a:
		s += str(i)
	return s
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	index_of0 = n
	index_of1 = n
	index_of_1 = n
	try:
		index_of_1 = a.index(-1)
	except:
		pass
	try:
		index_of0 = a.index(0)
	except:
		pass
	try:
		index_of1 = a.index(1)
	except:
		pass
	c = 0
	for i in range(1, n):
		if a[i] == b[i]:
			continue
		if a[i] < b[i]:
			if index_of1 < i:
				pass
			else:
				c = 1
				break
		elif a[i] > b[i]:
			if index_of_1 < i:
				pass
			else:
				c = 1
				break
	if c == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		t -= 1
		continue
	indexOfOne = 1000000001
	indexOfMinusOne = 1000000001
	flag = True
	if a[0] == 1:
		indexOfOne = 0
	elif a[0] == -1:
		indexOfMinusOne = 0
	for i in range(1, n):
		if a[i] == 1:
			indexOfOne = min(i, indexOfOne)
		if a[i] == -1:
			indexOfMinusOne = min(i, indexOfMinusOne)
		if b[i] > a[i]:
			if i <= indexOfOne:
				flag = False
				print('NO')
				break
		elif b[i] < a[i]:
			if i <= indexOfMinusOne:
				flag = False
				print('NO')
				break
	if flag:
		print('YES')
	t -= 1


for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(pf, nf) = (0, 0)
	ans = 1
	l = ['NO', 'YES']
	for i in range(0, n):
		diff = b[i] - a[i]
		if diff > 0 and pf == 1 or (diff < 0 and nf == 1) or diff == 0:
			ans = 1
		else:
			ans = 0
			break
		if a[i] == -1:
			nf = 1
		if a[i] == 1:
			pf = 1
	print(l[ans])


T = int(input())

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	count = {-1: 0, 0: 0, 1: 0}
	for a in A:
		count[a] += 1
	for i in range(len(B) - 1, -1, -1):
		count[A[i]] -= 1
		if A[i] == B[i]:
			continue
		if A[i] < B[i] and count[1] == 0:
			return 'NO'
		if A[i] > B[i] and count[-1] == 0:
			return 'NO'
	return 'YES'
for _ in range(T):
	print(solve())


def problem(n, a, b):
	for i in range(n):
		b[i] -= a[i]
	(dec, inc, i) = (False, False, 0)
	while (not dec or not inc) and i < n:
		if b[i] > 0 and (not inc) or (b[i] < 0 and (not dec)):
			return 'NO'
		if a[i] == 1:
			inc = True
		elif a[i] == -1:
			dec = True
		i += 1
	return 'YES'
for _ in range(int(input())):
	print(problem(int(input()), list(map(int, input().split())), list(map(int, input().split()))))


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	if a[0] != b[0]:
		print('NO')
		continue
	d = [0, 0]
	for i in range(n):
		if d == [0, 0]:
			if a[i] != b[i]:
				f += 1
		elif d == [1, 0]:
			if a[i] > b[i]:
				f += 1
		elif d == [0, 1]:
			if a[i] < b[i]:
				f += 1
		if a[i] == 1:
			d[0] = 1
		elif a[i] == -1:
			d[1] = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


def getAns(arr, result, n):
	s = set()
	if arr[0] != result[0]:
		return 'NO'
	s.add(arr[0])
	for i in range(1, n):
		if result[i] > arr[i]:
			if 1 not in s:
				return 'NO'
		if result[i] < arr[i]:
			if -1 not in s:
				return 'NO'
		s.add(arr[i])
	return 'YES'
T = int(input())
for t in range(T):
	n = int(input())
	arr = tuple(map(int, input().split()))
	result = tuple(map(int, input().split()))
	print(getAns(arr, result, n))


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


from sys import stdin
input = stdin.readline
for ti in range(int(input().strip())):
	n = int(input().strip())
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	(mini, maxa) = (a.count(-1), a.count(1))
	for i in range(n - 1, -1, -1):
		if a[i] == 1:
			maxa -= 1
		elif a[i] == -1:
			mini -= 1
		if a[i] > b[i]:
			if not mini:
				break
		elif a[i] < b[i]:
			if not maxa:
				break
	else:
		print('YES')
		continue
	print('NO')


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

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

def Lstr():
	return list(sys.stdin.readline().strip())

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

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		n = Int()
		a = List()
		b = List()
		mukul_p = False
		mukul_m = False
		for i in range(n):
			if b[i] - a[i] > 0 and mukul_p == False:
				print('NO')
				break
			if b[i] - a[i] < 0 and mukul_m == False:
				print('NO')
				break
			if a[i] > 0:
				mukul_p = True
			elif a[i] < 0:
				mukul_m = True
		else:
			print('YES')
solution()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	c = 0
	for i in range(n):
		if a[i] > b[i] and -1 not in s or (a[i] < b[i] and 1 not in s):
			c = 1
		s.add(a[i])
	if c == 0:
		print('YES')
	else:
		print('NO')


for x in range(int(input())):
	n = int(input())
	h = list(map(int, input().split()))
	m = list(map(int, input().split()))
	k = 0
	l = 0
	r = 'YES'
	for i in range(n):
		diff = m[i] - h[i]
		if diff == 0:
			m[i] = h[i]
		elif diff > 0 and k > 0:
			m[i] = h[i]
		elif diff < 0 and l < 0:
			m[i] = h[i]
		else:
			r = 'NO'
			break
		if h[i] == 1:
			k += 1
		if h[i] == -1:
			l -= 1
		i += 1
	print(r)


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
import sys
input = sys.stdin.readline
M = mod = 998244353

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('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	a = li()
	b = li()
	before = [[None] * 3 for i in range(n)]
	help = [0] * 3
	for i in range(n):
		for j in range(3):
			if help[j]:
				before[i][j] = 1
			if a[i] == j - 1:
				help[j] = 1
	ans = 'YES'
	for i in range(n):
		if a[i] < b[i]:
			if not before[i][2]:
				ans = 'NO'
				break
		elif a[i] > b[i]:
			if not before[i][0]:
				ans = 'NO'
				break
	print(ans)


testCases = int(input())
for t in range(testCases):
	length = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result = 'YES'
	oneExist = [False, False]
	for i1 in range(length):
		c = a[i1] - b[i1]
		if c != 0:
			if i1 == 0:
				result = 'NO'
				break
			elif c > 0:
				if not oneExist[0]:
					result = 'NO'
					break
			elif not oneExist[1]:
				result = 'NO'
				break
		if a[i1] == -1:
			oneExist[0] = True
		elif a[i1] == 1:
			oneExist[1] = True
	print(result)


def solve(test_case):
	n = read(int)
	A = read([int])
	B = read([int])
	has1 = False
	hasn1 = False
	for (a, b) in zip(A, B):
		diff = b - a
		if diff > 0 and (not has1):
			return print('NO')
		if diff < 0 and (not hasn1):
			return print('NO')
		has1 |= a == 1
		hasn1 |= a == -1
	print('YES')

def dp(f):
	cache = {}

	def g(*args):
		args = tuple(args)
		if args in cache:
			return cache[args]
		x = f(*args)
		cache[args] = x
		return x
	return g
MOD = 10 ** 9 + 7

class Config:
	has_tests = True
	debug = False
	print_recursion = False
	prime_sieve = 1
import itertools
import math
from collections import defaultdict
from collections import namedtuple
from heapq import heapify, heappop, heappush, heappushpop, heapreplace

def trie():
	return defaultdict(trie)

def _():
	print(heapify, heappop, heappush, heappushpop, heapreplace, namedtuple, math, itertools)

def is_prime(n):
	if n < 2:
		return False
	if n == 2:
		return True
	if n <= Config.prime_sieve:
		return spf[n] == n
	f = 3
	while f * f <= n:
		if n % f == 0:
			return False
	return True

def prime_factorize(n):
	if n <= 3:
		return [(n, 1)]
	factorization = []
	f = 2
	while f * f <= n > Config.prime_sieve:
		p = 0
		while n % f == 0:
			p += 1
			n //= f
		factorization.append((f, p))
		f += 1
	while 1 < n != spf[n]:
		p = 0
		f = spf[n]
		while n % f == 0:
			n //= f
			p += 1
		factorization.append((f, p))
	if n > 1:
		factorization.append((n, 1))
	return factorization

def count_factors(factorization, mod=None):
	ans = 1
	for (f, p) in factorization:
		ans *= 1 + p
		if mod is not None:
			ans %= mod
	return ans

def sum_of_factors(n, mod=None):
	pass

def ncr(n, r, mod=None):
	pass

def pow(n, p, mod=None):
	ans = 1
	while p > 0:
		if p % 2 == 1:
			ans *= n
			if mod is not None:
				ans %= mod
		n *= n
		if mod is not None:
			n %= mod
		p //= 2
	return ans

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def x_gcd(a, b):
	(px, x) = (1, 0)
	(py, y) = (0, 1)
	while b:
		q = a // b
		(x, px) = (px - q * x, x)
		(y, py) = (py - q * y, y)
		(a, b) = (b, a % b)
	return (a, px, py)

def mod_inv(n, m):
	(g, x, y) = x_gcd(n, m)
	if g == 1:
		return x % m
	return (x % m, g)

def mod_inv_multi(n, m):
	inv = [1] * (n + 1)
	for i in range(2, m):
		inv[i] = (m - m // i * inv[m % i] % m) % m
	return inv

def read(typ, times=None, delimiter=None):
	if times is not None:
		return [read(typ, times=None, delimiter=delimiter) for _ in range(times)]
	if isinstance(typ, list):
		return list(map(typ[0], input().strip().split(delimiter)))
	return typ(input().strip())

class BBST:
	pass

class SegmentTree:

	def __init__(self, values, combinator, updater):
		self.original = values
		self.combinator = combinator
		self.updater = updater
		n = len(values)
		tree = [] * (4 * n)
		for (i, val) in enumerate(values):
			tree[n + i] = val
		for i in reversed(range(n)):
			tree[i] = combinator(tree[2 * i], tree[2 * i + 1])
		self._tree = tree

	def query(self, start, end):
		combinator = self.combinator
		updater = self.updater
		tree = self._tree
		n = len(tree)
		start += n
		end += n
		pass

	def update(self, start, end, value):
		combinator = self.combinator
		updater = self.updater
		tree = self._tree
		n = len(tree)
		pass

class DisjointSet:

	def __init__(self):
		self._parents = {}
		self._rank = defaultdict(lambda : 1)

	def find(self, x):
		parent = self._parents.get(x, x)
		while parent != x:
			grand = self._parents.get(parent, parent)
			(x, parent, self._parents[x]) = (parent, grand, grand)
		return parent

	def rank(self, x):
		return self._rank[self.find(x)]

	def merge(self, x, y):
		(x, y) = (self.find(x), self.find(y))
		if self.rank(x) < self.rank(y):
			(x, y) = (y, x)
		self._parents[y] = x
		self._rank[x] += self._rank[y]
		del self._rank[y]

def sieve(n):
	global spf
	spf = [i for i in range(n + 1)]
	(spf[0], spf[1]) = (2, -1)
	i = 2
	while i * i <= n:
		if spf[i] == i:
			for j in range(i * i, n + 1, i):
				if i < spf[j]:
					spf[j] = i
		i += 1

def main():
	if Config.prime_sieve is not None:
		sieve(Config.prime_sieve)
	if Config.has_tests:
		for t in range(read(int)):
			solve(t)
	else:
		solve(None)
spf = []
main()


for i in range(int(input())):
	n = int(input())
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	st = set()
	for i in range(n):
		if arr1[i] == arr2[i]:
			st.add(arr1[i])
			continue
		elif arr1[i] > arr2[i]:
			if -1 in st:
				st.add(arr1[i])
				continue
			else:
				print('NO')
				break
		elif 1 in st:
			st.add(arr1[i])
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	neg = 10 ** 9
	pos = 10 ** 9
	flag = True
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(n):
			if a[i] == 1:
				pos = i
				break
		for i in range(n):
			if a[i] == -1:
				neg = i
				break
		for i in range(n - 1, 0, -1):
			if a[i] > b[i]:
				if neg != 10 ** 9 and neg < i:
					pass
				else:
					flag = False
					break
			if b[i] > a[i]:
				if pos != 10 ** 9 and pos < i:
					pass
				else:
					flag = False
					break
		if flag:
			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()))
	yes = 0
	no = 0
	now = 0
	prov = 0
	if a[0] == b[0]:
		for i in range(n):
			if a[i] != b[i]:
				if a[i] < b[i] and yes == 0:
					print('NO')
					prov = 1
					break
				elif a[i] > b[i] and no == 0:
					print('NO')
					prov = 1
					break
				else:
					if a[i] == 1:
						yes = 1
					if a[i] == -1:
						no = 1
			else:
				if a[i] == 1:
					yes = 1
				if a[i] == -1:
					no = 1
		if prov == 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()))
	tp = False
	tn = False
	t0 = False
	ans = False
	for i in range(n):
		if a[i] == b[i]:
			ans = True
		elif b[i] > a[i] and tp:
			ans = True
		elif b[i] < a[i] and tn:
			ans = True
		else:
			ans = False
		if ans == False:
			break
		if not (tp and tn):
			if a[i] == 1:
				tp = True
			elif a[i] == -1:
				tn = True
	if ans == True:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]
spf_sieve()

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	b = int_array()
	neg = pos = 0
	f = 1
	for i in range(n):
		if neg == 0:
			if b[i] < a[i]:
				f = 0
				break
		if pos == 0:
			if b[i] > a[i]:
				f = 0
				break
		if a[i] == -1:
			neg += 1
		elif a[i] == 1:
			pos += 1
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s1 = input().split()
	s2 = input().split()
	list1 = []
	list2 = []
	for i in range(0, n):
		list1.append(int(s1[i]))
	for i in range(0, n):
		list2.append(int(s2[i]))
	dict1 = {}
	for i in range(0, n):
		if list1[i] in dict1:
			dict1[list1[i]] += 1
		else:
			dict1[list1[i]] = 1
	bb = 1
	for i in range(n - 1, -1, -1):
		if list1[i] in dict1:
			dict1[list1[i]] -= 1
			if dict1[list1[i]] == 0:
				del dict1[list1[i]]
		if list2[i] > list1[i]:
			if 1 in dict1:
				p = 1
			else:
				bb = 0
				break
		elif list2[i] < list1[i]:
			if -1 in dict1:
				q = 1
			else:
				bb = 0
				break
	if bb == 1:
		print('YES', end='\n')
	else:
		print('NO', end='\n')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split(' ')))
		b = list(map(int, input().split(' ')))
		if a[0] != b[0]:
			print('NO')
			continue
		has = list(map(lambda x: set(), range(n)))
		for i in range(1, n):
			has[i] = has[i].union(has[i - 1])
			has[i].add(a[i - 1])
		no = False
		for i in range(1, n):
			if b[i] == a[i]:
				continue
			if b[i] > a[i]:
				needs = 1
			else:
				needs = -1
			if needs not in has[i]:
				no = True
				break
		if no:
			print('NO')
		else:
			print('YES')
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	visit = [0, 0, 0]
	f = True
	for i in range(n):
		if a[i] > b[i]:
			if visit[0] == 0:
				f = False
				break
		elif a[i] < b[i]:
			if visit[2] == 0:
				f = False
				break
		if visit[a[i] + 1] == 0:
			visit[a[i] + 1] = 1
	if f:
		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()))
	sa = set([])
	ch = 1
	for i in range(n):
		if a[i] == b[i]:
			if a[i] == 1 or a[i] == -1:
				sa.add(a[i])
		elif a[i] > b[i]:
			if -1 in sa:
				if b[i] <= 1 <= a[i]:
					sa.add(1)
			else:
				ch = 0
				break
		elif 1 in sa:
			if a[i] <= -1 <= b[i]:
				sa.add(-1)
		else:
			ch = 0
			break
	if ch == 1:
		print('YES')
	else:
		print('NO')


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


for __ in range(int(input())):
	n = int(input())
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	ans = 'YES'
	kek = set()
	for i in range(n):
		if ar2[i] > ar1[i] and 1 not in kek:
			ans = 'NO'
			break
		elif ar2[i] < ar1[i] and -1 not in kek:
			ans = 'NO'
			break
		kek.add(ar1[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	maxi = a[0]
	mini = a[0]
	ok = True
	if a[0] != b[0]:
		print('NO')
	elif n == 1:
		if a != b:
			print('NO')
		else:
			print('YES')
	else:
		for i in range(1, n):
			if b[i] > a[i] and maxi == 1:
				mini = min(a[i], mini)
				maxi = max(a[i], maxi)
				a[i] = b[i]
			elif b[i] < a[i] and mini == -1:
				mini = min(a[i], mini)
				maxi = max(a[i], maxi)
				a[i] = b[i]
			elif b[i] == a[i]:
				mini = min(a[i], mini)
				maxi = max(a[i], maxi)
			else:
				ok = False
				break
		if ok:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(p, neg) = (False, False)
	for i in range(n):
		if a[i] > b[i] and (not neg):
			print('NO')
			break
		if a[i] < b[i] and (not p):
			print('NO')
			break
		if a[i] == 1:
			p = True
		if a[i] == -1:
			neg = True
		if i == n - 1:
			print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	mx = [0] * n
	mn = [0] * n
	mx[0] = mn[0] = a[0]
	for i in range(1, n):
		mx[i] = max(a[i], mx[i - 1])
		mn[i] = min(a[i], mn[i - 1])
	b = [int(x) for x in input().split()]
	if a[0] != b[0]:
		print('NO')
	else:
		check = True
		for i in range(1, n):
			if b[i] > a[i] and mx[i - 1] == 1:
				continue
			if b[i] < a[i] and mn[i - 1] == -1:
				continue
			if b[i] == a[i]:
				continue
			check = False
		if check:
			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()))
	ones = 0
	neg = 0
	for i in range(n):
		if b[i] > a[i] and ones == 0:
			print('NO')
			break
		if b[i] < a[i] and neg == 0:
			print('NO')
			break
		if a[i] == 1:
			ones += 1
		if a[i] == -1:
			neg += 1
	else:
		print('YES')


import math

def main():
	was = set()
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		if a[i] - b[i] > 0:
			if not -1 in was:
				print('NO')
				return
		elif a[i] - b[i] < 0:
			if not 1 in was:
				print('NO')
				return
		was.add(a[i])
	print('YES')

def __starting_point():
	t = int(input())
	for i in range(t):
		main()
__starting_point()


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


counter = int(input())
for x in range(counter):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(one, neg) = (False, False)
	if a == b:
		print('YES')
		continue
	if a[0] != b[0]:
		print('NO')
		continue
	if a[0] == 1:
		one = True
	if a[0] == -1:
		neg = True
	found = True
	for i in range(1, n):
		if a[i] < b[i] and (not one):
			found = False
			print('NO')
			break
		elif a[i] > b[i] and (not neg):
			found = False
			print('NO')
			break
		if a[i] == 1:
			one = True
		if a[i] == -1:
			neg = True
	if found:
		print('YES')


import sys

def main():
	test_cases = int(sys.stdin.readline())
	for test_case in range(test_cases):
		n = int(sys.stdin.readline())
		given_nums = sys.stdin.readline().split()
		desired_nums = sys.stdin.readline().split()
		has_pos = False
		has_neg = False
		for i in range(n):
			num = int(given_nums[i])
			desired_num = int(desired_nums[i])
			delta = desired_num - num
			if delta > 0:
				if not has_pos:
					print('NO')
					break
			elif delta < 0:
				if not has_neg:
					print('NO')
					break
			if num > 0:
				has_pos = True
			elif num < 0:
				has_neg = True
			if i == n - 1:
				print('YES')
main()


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


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	plus = -1
	moins = -1
	out = 'YES'
	for i in range(n):
		if a[i] == -1 and moins == -1:
			moins = i + 1
		if a[i] == 1 and plus == -1:
			plus = i + 1
	for i in range(n):
		if b[i] < a[i] and (moins > i or moins == -1):
			out = 'NO'
			break
		if b[i] > a[i] and (plus > i or plus == -1):
			out = 'NO'
			break
	print(out)


import sys
from math import ceil
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	n = int(ri())
	a = Ri()
	b = Ri()
	nl = -1
	for i in range(len(a)):
		if a[i] < 0:
			nl = i
			break
	nr = -1
	flag = True
	for i in range(len(a)):
		if a[i] > 0:
			nr = i
			break
	for i in range(len(a) - 1, -1, -1):
		if a[i] > b[i]:
			if nl != -1 and nl < i:
				continue
			else:
				flag = False
				break
		elif a[i] < b[i]:
			if nr != -1 and nr < i:
				continue
			else:
				flag = False
				break
	if flag:
		YES()
	else:
		NO()


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dp = [[0 for i in range(3)] for j in range(n)]
	f1 = 0
	f2 = 0
	f3 = 0
	for j in range(n):
		dp[j][0] = f1
		dp[j][1] = f2
		dp[j][2] = f3
		if a[j] == -1:
			f1 = 1
		elif a[j] == 0:
			f2 = 1
		else:
			f3 = 1
	ans = True
	for j in range(n):
		if a[j] < b[j] and dp[j][2] == 0:
			ans = False
		elif a[j] > b[j] and dp[j][0] == 0:
			ans = False
	print('YES') if ans else print('NO')


def sign(x):
	if x > 0:
		return 1
	elif x < 0:
		return -1
	return 0
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	min_a = min(a)
	max_a = max(a)
	if min_a >= 0 and min(b) < 0:
		print('NO')
		continue
	if max_a <= 0 and max(b) > 0:
		print('NO')
		continue
	flag = True
	flag2 = True
	accum = n * [(False, False)]
	if a[0] == b[0] and a[0] != 0:
		if a[0] == -1:
			accum[0] = (False, True)
		if a[0] == 1:
			accum[0] = (True, False)
	for i in range(1, n):
		accum[i] = list(accum[i - 1])
		if not accum[i][0]:
			if a[i] == b[i]:
				if a[i] == 1:
					accum[i][0] = True
			elif accum[i][1]:
				if a[i] == 1:
					accum[i][0] = True
		if not accum[i][1]:
			if a[i] == b[i]:
				if a[i] == -1:
					accum[i][1] = True
			elif accum[i][0]:
				if a[i] == -1:
					accum[i][1] = True
	m = {-1: 1, 1: 0}
	for i in range(1, n):
		if a[i] != b[i] and (not (sign(b[i]) == 0 and (accum[i - 1][m[-sign(a[i])]] or accum[i - 1][m[-sign(a[i])]]) or (sign(b[i]) and accum[i - 1][m[sign(b[i])]]))):
			flag2 = False
			break
	if flag2:
		flag = False
	if flag:
		print('NO')
		continue
	print('YES')


from sys import stdin, stdout
t = int(stdin.readline())
while t > 0:
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	poss = True
	d = {}
	for i in range(n):
		if a[i] != b[i]:
			if b[i] > 0:
				if 1 not in d:
					poss = False
					break
			elif b[i] < 0:
				if -1 not in d:
					poss = False
					break
			elif a[i] == 1:
				if -1 not in d:
					poss = False
					break
			elif a[i] == -1:
				if 1 not in d:
					poss = False
					break
		d[a[i]] = 1
	if poss:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
	t -= 1


for _ in range(int(input())):
	qtd = int(input())
	(a, b) = (input().split(), input().split())
	(plus, minus) = (False, False)
	made = True
	for i in range(qtd):
		if plus and minus:
			break
		if int(a[i]) > int(b[i]):
			if not minus:
				made = False
				break
		if int(a[i]) < int(b[i]):
			if not plus:
				made = False
				break
		plus = int(a[i]) == 1 or plus
		minus = int(a[i]) == -1 or minus
	if made:
		print('YES')
	else:
		print('NO')


t = int(input())
for you in range(t):
	n = int(input())
	a = input().split()
	ai = [int(i) for i in a]
	b = input().split()
	bi = [int(i) for i in b]
	poss = 1
	numofzero = 0
	numofon = 0
	numofm = 0
	for i in range(n):
		if bi[i] > ai[i] and numofon == 0:
			poss = 0
			break
		elif bi[i] < ai[i] and numofm == 0:
			poss = 0
			break
		if ai[i] == 1:
			numofon += 1
		elif ai[i] == -1:
			numofm += 1
		else:
			numofzero += 1
	if poss == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	one_ex = False
	mone_ex = False
	flag = True
	for i in range(len(a)):
		if a[i] > b[i] and (not mone_ex):
			print('NO')
			flag = False
			break
		elif a[i] < b[i] and (not one_ex):
			print('NO')
			flag = False
			break
		if a[i] == 1:
			one_ex = True
		if a[i] == -1:
			mone_ex = True
	if flag:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c1 = False
	c0 = False
	flag = 0
	for i in range(n):
		if b[i] > a[i]:
			if c1 == False:
				flag = 1
				break
		elif b[i] < a[i]:
			if c0 == False:
				flag = 1
				break
		if a[i] == 1:
			c1 = True
		if a[i] == -1:
			c0 = True
	if flag == 0:
		print('YES')
	else:
		print('NO')


def solve_case():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	seen_1 = False
	seen_minus_1 = False
	for (ai, bi) in zip(a, b):
		if ai == bi:
			if ai == 1:
				seen_1 = True
			elif ai == -1:
				seen_minus_1 = True
			continue
		if bi < ai:
			if not seen_minus_1:
				return 'NO'
			if ai == 1:
				seen_1 = True
			elif ai == -1:
				seen_minus_1 = True
			continue
		if bi > ai:
			if not seen_1:
				return 'NO'
			if ai == 1:
				seen_1 = True
			elif ai == -1:
				seen_minus_1 = True
	return 'YES'

def main():
	tests = int(input())
	for t in range(1, tests + 1):
		print(solve_case())
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	diff = [b[i] - a[i] for i in range(n)]
	s = 0
	check = float('inf') if 1 not in a else a.index(1)
	check2 = float('inf') if -1 not in a else a.index(-1)
	for i in range(n):
		s += a[i]
		if s == 1:
			check = min(check, i)
		if s == -1:
			check2 = min(check2, i)
	for i in range(n):
		if diff[i] > 0 and check >= i:
			print('NO')
			break
		elif diff[i] < 0 and check2 >= i:
			print('NO')
			break
	else:
		print('YES')


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


for _ in range(int(input())):
	n = int(input())
	flag = 0
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	z = set()
	for i in range(n):
		if a[i] > b[i] and -1 not in z or (a[i] < b[i] and 1 not in z):
			flag = 1
			break
		else:
			z.add(a[i])
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
import bisect
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()
mint = lambda : map(int, inp().split())

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	n = iinp()
	a = intl()
	b = intl()
	have = [0, 0]
	flag = 0
	for i in range(n):
		if a[i] > b[i] and have[0] == 0:
			print('NO')
			flag = 1
			break
		elif a[i] < b[i] and have[1] == 0:
			print('NO')
			flag = 1
			break
		if a[i] == -1:
			have[0] = 1
		if a[i] == 1:
			have[1] = 1
	if flag == 0:
		print('YES')
for _ in range(iinp()):
	solve()


t = int(input())
for _ in range(t):
	n = input()
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	negative = False
	positive = False
	result = True
	for i in range(int(n)):
		if b[i] > a[i] and (not positive):
			result = False
			break
		if b[i] < a[i] and (not negative):
			result = False
			break
		if a[i] == 1:
			positive = True
		if a[i] == -1:
			negative = True
	if result:
		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()))
	c = 0
	d = 0
	h = 0
	e = 0
	for i in range(n):
		if a[i] > 0:
			c += 1
		if a[i] < 0:
			d += 1
		else:
			h += 1
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(n - 1, -1, -1):
			if a[i] == 0:
				h -= 1
			if a[i] == 1:
				c -= 1
			if a[i] == -1:
				d -= 1
			if a[i] > b[i]:
				if d > 0:
					continue
				else:
					e = 1
					break
			if a[i] < b[i]:
				if c > 0:
					continue
				else:
					e = 1
					break
		if e == 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [0] * 4
	for i in range(n):
		if b[i] > a[i]:
			if not c[1]:
				print('NO')
				break
		elif b[i] < a[i]:
			if not c[-1]:
				print('NO')
				break
		c[a[i]] += 1
	else:
		print('YES')


t = int(input())
while t != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	(zer, minu, one) = (0, 0, 0)
	for i in range(n):
		if list1[i] == 0:
			zer += 1
		elif list1[i] == 1:
			one += 1
		else:
			minu += 1
	f1 = 0
	for i in range(len(list1) - 1, -1, -1):
		if list1[i] == 0:
			zer -= 1
		elif list1[i] == 1:
			one -= 1
		else:
			minu -= 1
		if list2[i] > list1[i]:
			if one <= 0:
				print('NO')
				f1 = 1
				break
		elif list2[i] < list1[i]:
			if minu <= 0:
				print('NO')
				f1 = 1
				break
	if f1 == 0:
		print('YES')
	t -= 1


for _ in range(int(input())):
	nums = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if a == b:
		print('YES')
		continue
	add_done = subtract_done = False
	if -1 not in a:
		subtract_done = True
		can_subtract = [False] * nums
	if 1 not in a:
		add_done = True
		can_add = [False] * nums
	for i in range(nums):
		if add_done and subtract_done:
			break
		if not add_done:
			if a[i] == 1:
				can_add = [False] * (i + 1)
				can_add += [True] * (nums - (i + 1))
				add_done = True
		if not subtract_done:
			if a[i] == -1:
				can_subtract = [False] * (i + 1)
				can_subtract += [True] * (nums - (i + 1))
				subtract_done = True
	for i in range(nums):
		if a[i] > b[i]:
			if not can_subtract[i]:
				print('NO')
				break
		elif a[i] < b[i]:
			if not can_add[i]:
				print('NO')
				break
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	(cnt, res) = ([0] * 3, 1)
	for x in a:
		cnt[x + 1] += 1
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			cnt[a[i] + 1] -= 1
			continue
		elif a[i] < b[i]:
			if a[i] == 1 and cnt[2] == 1 or cnt[2] == 0:
				res = 0
				break
			else:
				cnt[a[i] + 1] -= 1
		elif a[i] == -1 and cnt[0] == 1 or cnt[0] == 0:
			res = 0
			break
		else:
			cnt[a[i] + 1] -= 1
	print('YES' if res else 'NO')


def soln(a, b):
	hasPos = [False]
	hasNeg = [False]
	for i in range(len(a)):
		currPos = hasPos[-1]
		currNeg = hasNeg[-1]
		if a[i] == 1:
			currPos = True
		elif a[i] == -1:
			currNeg = True
		hasPos.append(currPos)
		hasNeg.append(currNeg)
	for i in range(len(a)):
		if not (b[i] > a[i] and hasPos[i] or (b[i] < a[i] and hasNeg[i]) or b[i] == a[i]):
			return False
	return True

def main():
	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(' ')]
		result = soln(a, b)
		if result is True:
			print('YES')
		else:
			print('NO')

def test():
	a = [1, -1, 0]
	b = [1, 1, -2]
	print(soln(a, b))
main()


t = int(input())
for cs in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pl = 0
	mn = 0
	mark = 0
	for i in range(0, n):
		if a[i] == 1:
			pl += 1
		elif a[i] == -1:
			mn += 1
	for i in range(0, n):
		if a[n - i - 1] == 1:
			pl -= 1
		elif a[n - i - 1] == -1:
			mn -= 1
		if a[n - i - 1] == b[n - i - 1]:
			continue
		elif a[n - i - 1] < b[n - i - 1]:
			if pl > 0:
				continue
			else:
				mark = 1
		elif mn > 0:
			continue
		else:
			mark = 1
	if mark == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for x in range(n):
	l = int(input())
	isminus = False
	isplus = False
	m1 = list(map(int, input().split()))
	m2 = list(map(int, input().split()))
	for z in range(l):
		if m1[z] != m2[z]:
			if m1[z] < m2[z] and isplus == False:
				print('NO')
				break
			if m1[z] > m2[z] and isminus == False:
				print('NO')
				break
		if m1[z] == 1:
			isplus = True
		if m1[z] == -1:
			isminus = True
		if isminus and isplus:
			print('YES')
			break
	else:
		print('YES')


test = int(input())
for i in range(test):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(k) for k in input().split()]
	ans = ''
	if a[0] != b[0]:
		ans = 'NO'
	else:
		pos = 0
		neg = 0
		for i in range(n):
			if a[i] > b[i] and (not neg):
				ans = 'NO'
				break
			elif a[i] < b[i] and (not pos):
				ans = 'NO'
				break
			else:
				if a[i] == 1:
					pos += 1
				elif a[i] == -1:
					neg += 1
				ans = 'YES'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	seen = [False, False, False]
	flag = True
	for (i, a) in enumerate(arr):
		b = brr[i]
		if a != b:
			if a < b and seen[1] == False:
				flag = False
			elif a > b and seen[-1] == False:
				flag = False
		seen[a] = True
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = True
	f1 = False
	f2 = False
	for i in range(n):
		if b[i] > a[i]:
			if f1 == False:
				flag = False
				break
		elif b[i] < a[i]:
			if f2 == False:
				flag = False
				break
		if a[i] == 1:
			f1 = True
		elif a[i] == -1:
			f2 = True
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(c) for c in input().split()]
	b = [int(c) for c in input().split()]
	pos = False
	neg = False
	for i in range(n):
		if a[i] > b[i] and (not neg):
			print('NO')
			break
		elif a[i] < b[i] and (not pos):
			print('NO')
			break
		if a[i] == 1:
			pos = True
		elif a[i] == -1:
			neg = True
		if pos and neg:
			print('YES')
			break
	else:
		print('YES')


from sys import stdin

def solve(n, a, b):
	ans = 'YES'
	k = 0
	for i in range(n):
		if k == 0:
			if a[i] != b[i]:
				ans = 'NO'
				break
			if a[i] > 0:
				k = 1
			elif a[i] < 0:
				k = 2
		elif k == 1:
			if b[i] < a[i]:
				ans = 'NO'
				break
			if a[i] < 0:
				k = 3
		elif k == 2:
			if b[i] > a[i]:
				ans = 'NO'
				break
			if a[i] > 0:
				k = 3
		else:
			break
	print(ans)

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		n = int(inp())
		a = list(map(int, inp().split()))
		b = list(map(int, inp().split()))
		solve(n, a, b)
main()


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


for _ in range(int(input())):
	n = int(input())
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	if arr1[0] != arr2[0]:
		print('NO')
	else:
		check = {arr1[0]}
		for i in range(1, n):
			if arr2[i] > arr1[i] and 1 not in check:
				print('NO')
				break
			elif arr2[i] < arr1[i] and -1 not in check:
				print('NO')
				break
			check.add(arr1[i])
		else:
			print('YES')


t = int(input())
out = list()
for stuff in range(t):
	input_n = input()
	input_a = input().split()
	input_b = input().split()
	n = int(input_n)
	a = [int(item) for item in input_a]
	b = [int(item) for item in input_b]
	neg = 0
	pos = 0
	OK = 0
	for i in range(n):
		if i == 0 and a[i] != b[i]:
			out.append('NO')
			break
		if a[i] < b[i] and pos == 1:
			OK = OK + 1
		elif a[i] > b[i] and neg == 1:
			OK = OK + 1
		elif a[i] == b[i]:
			OK = OK + 1
		else:
			out.append('NO')
			break
		if a[i] == -1:
			neg = 1
		elif a[i] == 1:
			pos = 1
	if OK == n:
		out.append('YES')
for item in out:
	print(item)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mn = 0
	pl = 0
	no = 0
	if a[0] != b[0]:
		print('NO')
		continue
	for i in range(N - 1):
		if a[i] > 0:
			pl = 1
		elif a[i] < 0:
			mn = 1
		if a[i + 1] < b[i + 1] and pl == 0:
			no = 1
			break
		if a[i + 1] > b[i + 1] and mn == 0:
			no = 1
			break
	if no:
		print('NO')
	else:
		print('YES')


T = int(input())
for _ in range(1, T + 1):
	L = int(input())
	ar1 = [int(x) for x in input().split()]
	ar2 = [int(x) for x in input().split()]
	seen_pos = seen_neg = False
	for (a, b) in zip(ar1, ar2):
		if a > b and (not seen_neg) or (a < b and (not seen_pos)):
			print('NO')
			break
		if a > 0:
			seen_pos = True
		if a < 0:
			seen_neg = True
	else:
		print('YES')


for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dic = {1: 0, -1: 0, 0: 0}
	f = 0
	for i in range(n):
		if a[i] == b[i]:
			dic[a[i]] = 1
		elif b[i] > a[i]:
			if dic[1] == 0:
				f = 1
				break
			else:
				dic[a[i]] = 1
		elif b[i] < a[i]:
			if dic[-1] == 0:
				f = 1
				break
			else:
				dic[a[i]] = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	diff = [0] * n
	for i in range(n):
		if b[i] - a[i]:
			diff[i] = (b[i] - a[i]) // abs(b[i] - a[i])
		else:
			diff[i] = b[i] - a[i]
	ct = [0, 1, 0]
	z = 1
	for i in range(n):
		if ct[diff[i] + 1] == 0:
			z = 0
			break
		ct[a[i] + 1] += 1
	if z:
		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 a[0] != b[0]:
		print('NO')
	else:
		(pos, neg) = (False, False)
		if a[0] > 0:
			pos = True
		elif a[0] < 0:
			neg = True
		flag = 0
		for i in range(1, n):
			if a[i] < b[i] and pos == False or (a[i] > b[i] and neg == False):
				flag = 1
				break
			if a[i] > 0:
				pos = True
			elif a[i] < 0:
				neg = True
		if flag == 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()))
	if a[0] != b[0]:
		print('NO')
		continue
	(p, m, f) = (0, 0, 0)
	if a[0] == 1:
		p = 1
	elif a[0] == -1:
		m = 1
	for i in range(1, n):
		if b[i] - a[i] > 0 and p == 0 or (b[i] - a[i] < 0 and m == 0):
			f = 1
			break
		if a[i] == 1:
			p = 1
		elif a[i] == -1:
			m = 1
		if p == m == 1:
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from itertools import permutations, combinations
from collections import defaultdict, deque
import bisect as bi
import sys

def I():
	return int(input())

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

def main():
	try:
		for _ in range(I()):
			n = I()
			l = list(In())
			b = list(In())
			kira = set()
			q = 0
			for x in range(n):
				if b[x] > l[x]:
					if 1 not in kira:
						q = 1
						break
					kira.add(l[x])
				elif b[x] == l[x]:
					kira.add(l[x])
					continue
				else:
					if -1 not in kira:
						q = 1
						break
					kira.add(l[x])
			if q == 1:
				print('NO')
			else:
				print('YES')
	except:
		pass
M = 998244353
P = 1000000007

def mod(a, b, c):
	res = a * b
	if res >= c:
		return res % c
	else:
		return res

def expo(a, b):
	(x, y) = (1, a)
	while b > 0:
		if b & 1:
			x = x * y
		y = y * y
		b >>= 1
	return x

def modInverse(b, M):
	g = math.gcd(b, M)
	if g != 1:
		return -1
	else:
		return pow(b, M - 2, M)

def modDivide(a, b, M):
	a = a % M
	inv = modInverse(b, M)
	if inv == -1:
		return -1
	else:
		return inv * a % M
main()


t = int(input())
for ii in range(t):
	n = int(input())
	lsa = list(map(int, input().split()))
	lsb = list(map(int, input().split()))
	flag = 1
	pos = 0
	neg = 0
	for i in range(n):
		if lsa[i] != lsb[i]:
			if i == 0:
				flag = 0
				break
			elif lsb[i] < 0 and neg == 1:
				flag = 1
			elif lsb[i] > 0 and pos == 1:
				flag = 1
			elif lsb[i] == 0 and lsa[i] < 0 and (pos == 1):
				flag = 1
			elif lsb[i] == 0 and lsa[i] > 0 and (neg == 1):
				flag = 1
			else:
				flag = 0
				break
		if lsa[i] < 0:
			neg = 1
		elif lsa[i] > 0:
			pos = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {1: [], -1: []}
	for i in range(n):
		if a[i] == 1:
			d[1].append(i)
		elif a[i] == -1:
			d[-1].append(i)
	flag = True
	for i in range(n - 1, -1, -1):
		if b[i] == a[i]:
			continue
		elif b[i] > a[i]:
			temp_flag = False
			for index in d[1]:
				if index < i:
					temp_flag = True
					break
			if not temp_flag:
				flag = False
				break
		elif b[i] < a[i]:
			temp_flag = False
			for index in d[-1]:
				if index < i:
					temp_flag = True
					break
			if not temp_flag:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = []
	D = {}
	for (count, i) in enumerate(input().split()):
		a += [int(i)]
		if count == 0:
			D[count] = {int(i)}
		else:
			D[count] = D[count - 1].union({int(i)})
	b = list(map(int, input().split()))
	res = 'YES'
	for (count, i) in enumerate(b[::-1]):
		if count == n - 1 and i != a[-count - 1]:
			res = 'NO'
			break
		if i < a[-count - 1]:
			if -1 in D[n - count - 1 - 1]:
				continue
			else:
				res = 'NO'
				break
		elif i > a[-count - 1]:
			if 1 in D[n - count - 1 - 1]:
				continue
			else:
				res = 'NO'
				break
	print(res)


import sys
input = sys.stdin.readline

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

def f():
	n = int(input())
	l1 = input_list()
	l2 = input_list()
	possible = True
	deja_vu = set([])
	for (i, x) in enumerate(l1):
		if not possible:
			break
		if x != l2[i]:
			if x > l2[i] and -1 not in deja_vu:
				possible = False
			elif x < l2[i] and 1 not in deja_vu:
				possible = False
		if x not in deja_vu:
			deja_vu.add(x)
	if possible:
		print('YES')
	else:
		print('NO')

def main():
	t = int(input())
	for _ in range(t):
		f()
main()


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	N = Scanner.int()
	A = Scanner.map_int()
	B = Scanner.map_int()
	M = {}
	M[-1] = 0
	M[1] = 0
	for a in A:
		if a < 0:
			M[-1] += 1
		elif a > 0:
			M[1] += 1
	for i in reversed(range(N)):
		if A[i] > 0:
			M[1] -= 1
		elif A[i] < 0:
			M[-1] -= 1
		x = B[i] - A[i]
		if x == 0:
			continue
		if x > 0 and M[1] > 0:
			continue
		elif x < 0 and M[-1] > 0:
			continue
		print('NO')
		return
	print('YES')
	return

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


import sys
input = sys.stdin.readline

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

def array_print(arr):
	print(' '.join(map(str, arr)))
for t in range(int(input())):
	n = int(input())
	a = list(multi_input())
	b = list(multi_input())
	value1 = False
	value_1 = False
	ans = True
	if a[0] == b[0]:
		if a[0] == 1:
			value1 = True
		elif a[0] == -1:
			value_1 = True
		for i in range(n):
			if a[i] != b[i]:
				if a[i] < b[i]:
					if not value1:
						ans = False
						break
				elif a[i] > b[i]:
					if not value_1:
						ans = False
						break
			if a[i] == 1:
				value1 = True
			elif a[i] == -1:
				value_1 = True
	else:
		ans = False
	if ans:
		print('YES')
	else:
		print('NO')


from collections import *
from math import *
t = int(input())
for y in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ch = [[0, 0] for i in range(n)]
	for i in range(1, n):
		ch[i][0] = ch[i - 1][0]
		ch[i][1] = ch[i - 1][1]
		if a[i - 1] == 1:
			ch[i][1] += 1
		elif a[i - 1] == -1:
			ch[i][0] += 1
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		elif a[i] < b[i]:
			if ch[i][1] == 0:
				print('NO')
				break
		elif ch[i][0] == 0:
			print('NO')
			break
	else:
		print('YES')


def solve(n, a, b):
	vu1 = False
	vu2 = False
	for i in range(n):
		if not vu1 and (not vu2):
			if b[i] != a[i]:
				return 'NO'
		elif not vu1:
			if b[i] > a[i]:
				return 'NO'
		elif not vu2:
			if b[i] < a[i]:
				return 'NO'
		else:
			return 'YES'
		if a[i] == 1:
			vu1 = True
		elif a[i] == -1:
			vu2 = True
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = solve(n, a, b)
	print(s)


def solve(n, a, b):
	ones = []
	for i in range(n):
		if a[i] < b[i]:
			if 1 in ones:
				pass
			else:
				return 'NO'
		elif a[i] > b[i]:
			if -1 in ones:
				pass
			else:
				return 'NO'
		if a[i] not in ones:
			ones.append(a[i])
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(n, a, b))


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if a[0] != b[0]:
		print('NO')
	elif n == 1:
		print('YES')
	else:
		iterations = 0
		uch = set([a[0]])
		for i in range(1, n):
			iterations += 1
			if len(uch) == 3:
				print('YES')
				iterations -= 1
				break
			elif uch == {1, -1}:
				print('YES')
				iterations -= 1
				break
			elif b[i] > a[i]:
				if 1 in uch:
					uch.add(a[i])
					continue
				else:
					print('NO')
					iterations -= 1
					break
			elif b[i] == a[i]:
				uch.add(a[i])
				continue
			elif b[i] < a[i]:
				if -1 in uch:
					uch.add(a[i])
					continue
				else:
					print('NO')
					iterations -= 1
					break
			else:
				print('TNP')
		if iterations == n - 1:
			print('YES')


T = int(input())
for i in range(T):
	n = int(input())
	a = []
	k = list(map(int, input().split()))
	for j in k:
		a.append(int(j))
	b = []
	k = list(map(int, input().split()))
	for j in k:
		b.append(int(j))
	upflag = 0
	downflag = 0
	failure = 0
	for j in range(n):
		if upflag == 0 and b[j] > a[j]:
			failure = 1
			break
		if downflag == 0 and b[j] < a[j]:
			failure = 1
			break
		if a[j] == 1:
			upflag = 1
		if a[j] == -1:
			downflag = 1
	if failure == 1:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d = {}
	check = 0
	for j in range(n):
		m = l2[j] - l1[j]
		if m > 0:
			if d.get(1) == None:
				check = 1
				break
		if m < 0:
			if d.get(-1) == None:
				check = 1
				break
		if d.get(l1[j]) == None:
			d[l1[j]] = 1
	if check == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	pos1 = a.index(1) if 1 in a else 100001
	pos2 = a.index(-1) if -1 in a else 100001
	flag = True
	for i in range(n):
		if a[i] > b[i] and i <= pos2:
			flag = False
			break
		elif a[i] < b[i] and i <= pos1:
			flag = False
			break
	print('YES' if flag else 'NO')


for i in range(int(int(input()))):
	a = int(int(input()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	(p, q) = (0, 0)
	r = 0
	for j in range(a):
		if b[j] == c[j] or (b[j] > c[j] and q > 0) or (b[j] < c[j] and p > 0):
			r += 1
			if b[j] > 0:
				p += 1
			elif b[j] < 0:
				q += 1
		else:
			break
	if r == a:
		print('YES')
	else:
		print('NO')


import base64, codecs
magic = 'ZGVmIE5PKCk6IHJldHVybiBwcmludCgiTk8iKQ0KZGVmIFlFUygpOiByZXR1cm4gcHJpbnQoIllFUyIpDQpkZWYgSU5UKCk6IHJldHVybiBpbnQoaW5wdXQoKSkNCmRlZiBMSVNUKCk6IHJldHVybiBsaXN0KG1hcChpbnQsIGlucHV0KCkuc3'
love = 'OfnKDbXFxcQDcxMJLtH1EFXPx6VUWyqUIlovOcoaO1qPtcQDcxMJLtGHSDXPx6VUWyqUIlovOgLKNbnJ50YPOcoaO1qPtcYaAjoTy0XPxcQDbAPzMipvO4VTyhVUWuozqyXRyBIPtcXFN6QDbWovN9VRyBIPtcQDbWLlN9VSfjKFNdVQZAPtyu'
god = 'ID0gTElTVCgpDQoJYiA9IExJU1QoKQ0KCWZvciBpIGluIHJhbmdlKG4pOiBjW2FbaV0gKyAxXSArPSAxDQoJY2hlY2sgPSBGYWxzZQ0KCWZvciBpIGluIHJhbmdlKG4gLSAxLCAtMSwgLTEpIDoNCgkJY1thW2ldICsgMV0gLT0gMQ0KCQlpZi'
destiny = 'OuJ2yqVQ4tLygcKGbAPtxWPJyzVTAoZS0tCG0tZQbAPtxWPDywnTIwnlN9VSElqJHAPtxWMJkcMvOuJ2yqVQjtLygcKGbAPtxWPJyzVTAoZy0tCG0tZQbAPtxWPDywnTIwnlN9VSElqJHAPtyMEIZbXFOcMvOho3DtL2uyL2ftMJkmMFOBGltc'
joy = 'rot13'
trust = eval('magic') + eval('codecs.decode(love, joy)') + eval('god') + eval('codecs.decode(destiny, joy)')
eval(compile(base64.b64decode(eval('trust')), '<string>', 'exec'))


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(one, neg, zer, end) = (0, 0, 0, 0)
	for i in range(len(a)):
		if one == 1 and neg == 1:
			print('YES')
			end = 1
			break
		elif a[i] < b[i] and one == 0:
			print('NO')
			end = 1
			break
		elif a[i] > b[i] and neg == 0:
			print('NO')
			end = 1
			break
		else:
			pass
		if a[i] == 1:
			one = 1
		elif a[i] == -1:
			neg = 1
	if end == 0:
		print('YES')
	t -= 1


from sys import stdin
q = int(input())
for _ in range(q):
	ans = 'YES'
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	if a[0] != b[0]:
		print('NO')
	elif a == b:
		print('YES')
	else:
		x = 0
		y = 0
		if a[0] == -1:
			x += 1
		elif a[0] == 1:
			y += 1
		for i in range(1, n):
			if a[i] > b[i]:
				if x == 0:
					ans = 'NO'
					break
			elif a[i] < b[i]:
				if y == 0:
					ans = 'NO'
					break
			if x > 0 and y > 0:
				break
			if a[i] == -1:
				x += 1
			elif a[i] == 1:
				y += 1
		print(ans)


t = int(input())
while t > 0:
	n = int(input())
	minus = False
	plus = False
	ans = 'YES'
	for (a, b) in zip(map(int, input().split()), map(int, input().split())):
		d = b - a
		if d < 0 and (not minus) or (d > 0 and (not plus)):
			ans = 'NO'
			break
		if a == -1:
			minus = True
		elif a == 1:
			plus = True
	print(ans)
	t -= 1


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()]
	c = [0]
	tr = 1
	for i in range(n):
		d = b[i] - a[i]
		if d > 0 and 1 not in c:
			tr = 0
			break
		elif d < 0 and -1 not in c:
			tr = 0
			break
		if a[i] not in c:
			c.append(a[i])
	if tr == 0:
		print('NO')
	else:
		print('YES')


def solve():
	n = int(input())
	arr = [int(v) for v in input().split()]
	brr = [int(v) for v in input().split()]
	st = set()
	for i in range(n):
		if brr[i] < arr[i] and -1 not in st or (brr[i] > arr[i] and 1 not in st):
			print('NO')
			return
		st.add(arr[i])
	print('YES')
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if a == b:
		print('YES')
	else:
		p0 = False
		p1 = False
		p_1 = False
		chk = 1
		for x in range(n):
			if a[x] == b[x]:
				if a[x] == 0:
					p0 = True
				elif a[x] == 1:
					p1 = True
				elif a[x] == -1:
					p_1 = True
			if b[x] > a[x]:
				if p1 == True:
					if a[x] == 0:
						p0 = True
					elif a[x] == 1:
						p1 = True
					elif a[x] == -1:
						p_1 = True
					continue
				else:
					chk = 0
					break
			if b[x] < a[x]:
				if p_1 == True:
					if a[x] == 0:
						p0 = True
					elif a[x] == 1:
						p1 = True
					elif a[x] == -1:
						p_1 = True
					continue
				else:
					chk = 0
					break
		if chk == 1:
			print('YES')
		else:
			print('NO')


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

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

def solve():
	n = ri()
	A = rl()
	B = rl()
	(pos, neg) = (False, False)
	for i in range(n):
		if not neg and B[i] < A[i]:
			print('NO')
			return
		if not pos and B[i] > A[i]:
			print('NO')
			return
		if A[i] == 1:
			pos = True
		if A[i] == -1:
			neg = True
		if pos and neg:
			break
	print('YES')
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	get = True
	p = m = -1
	for i in range(n):
		if a[i] == -1:
			m = i
			break
	for i in range(n):
		if a[i] == 1:
			p = i
			break
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		elif a[i] > b[i]:
			if m == -1 or m >= i:
				get = False
				break
		elif p == -1 or p >= i:
			get = False
			break
	if get:
		print('YES')
	else:
		print('NO')


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


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


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(a, b):
	n = len(a)
	try:
		one_idx = a.index(1)
	except:
		one_idx = len(a)
	try:
		minus_one_idx = a.index(-1)
	except:
		minus_one_idx = len(a)
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			None
		if a[i] < b[i]:
			if one_idx < i:
				pos_flag = True
			else:
				pos_flag = False
				return 'NO'
		if a[i] > b[i]:
			if minus_one_idx < i:
				neg_flag = True
			else:
				neg_flag = False
				return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	a = to_list(input())
	b = to_list(input())
	print(solve(a, b))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()[:n]]
	b = [int(k) for k in input().split()[:n]]
	d = {}
	f = 0
	if a[0] != b[0]:
		print('NO')
	else:
		for l in range(n):
			if a[l] not in d:
				d[a[l]] = l
				if len(d) == 3:
					break
		for v in range(1, n):
			if b[v] > 0 and a[v] != b[v]:
				if 1 in d:
					x1 = d.get(1)
					if x1 < v:
						pass
					else:
						f = 1
						break
				else:
					f = 1
					break
			elif b[v] < 0 and a[v] != b[v]:
				if -1 in d:
					x2 = d.get(-1)
					if x2 < v:
						pass
					else:
						f = 1
						break
				else:
					f = 1
					break
			elif b[v] == 0 and a[v] != b[v]:
				if a[v] < 0:
					if 1 in d:
						x3 = d.get(1)
						if x3 < v:
							pass
						else:
							f = 1
							break
					else:
						f = 1
						break
				elif a[v] > 0:
					if -1 in d:
						x4 = d.get(-1)
						if x4 < v:
							pass
						else:
							f = 1
							break
					else:
						f = 1
						break
		if f == 0:
			print('YES')
		else:
			print('NO')


import bisect
import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading
from itertools import combinations

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

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

def solve():
	pass
for _ in range(iinput()):
	n = iinput()
	a = rlinput()
	b = rlinput()
	if a[0] != b[0]:
		print('NO')
	else:
		flag = True
		pos = False
		neg = False
		one = n + 1
		if 1 in a:
			one = a.index(1)
		mone = n + 1
		if -1 in a:
			mone = a.index(-1)
		for i in range(n - 1, 0, -1):
			diff = b[i] - a[i]
			if diff < 0 and mone >= i:
				flag = False
				break
			elif diff > 0 and one >= i:
				flag = False
				break
		print(['NO', 'YES'][flag])


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	for i in range(n):
		if a[i] > b[i] and -1 not in s or (a[i] < b[i] and 1 not in s):
			print('NO')
			break
		s.add(a[i])
	else:
		print('YES')


from collections import Counter
t = int(input())
for _ in range(t):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	counter = Counter(a)
	possible = True
	for idx in range(len(b) - 1, -1, -1):
		a_value = a[idx]
		b_value = b[idx]
		counter[a_value] -= 1
		counter += Counter()
		if a_value < b_value and 1 not in counter or (a_value > b_value and -1 not in counter):
			possible = False
			break
	if possible:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	dp = [0, 0, 0]
	z = True
	for i in range(n):
		if a[i] == b[i]:
			dp[a[i]] += 1
			continue
		if a[i] > b[i]:
			if dp[-1] == 0:
				z = False
				break
		if a[i] < b[i]:
			if dp[1] == 0:
				z = False
				break
		dp[a[i]] += 1
	if z:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	one_ = False
	none_ = False
	ans = True
	for i in range(n):
		if a[i] != b[i]:
			if b[i] > a[i]:
				if not one_:
					ans = False
					break
			elif b[i] < a[i]:
				if not none_:
					ans = False
					break
		if a[i] == 1:
			one_ = True
		elif a[i] == -1:
			none_ = True
	if ans:
		print('YES')
	else:
		print('NO')


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
while t > 0:
	t -= 1
	n = int(inp().strip())
	a = [int(k) for k in inp().strip().split()]
	b = [int(k) for k in inp().strip().split()]
	postiveFound = False
	negFound = False
	if a[0] != b[0]:
		print('NO')
		continue
	if a[0] > 0:
		postiveFound = True
	elif a[0] < 0:
		negFound = True
	for i in range(1, len(a)):
		if a[i] != b[i]:
			if a[i] < b[i] and (not postiveFound) or (a[i] > b[i] and (not negFound)):
				break
		if a[i] > 0:
			postiveFound = True
		elif a[i] < 0:
			negFound = True
	else:
		print('YES')
		continue
	print('NO')


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	t = 1
	pos = n - 1
	neg = n - 1
	for i in range(n):
		if a[i] > 0:
			pos = i
			break
	for i in range(n):
		if a[i] < 0:
			neg = i
			break
	if pos > neg:
		for i in range(neg + 1):
			if b[i] != a[i]:
				t = 0
				break
		for i in range(neg + 1, pos + 1):
			if b[i] > a[i]:
				t = 0
				break
	else:
		for i in range(pos + 1):
			if b[i] != a[i]:
				t = 0
				break
		for i in range(pos + 1, neg + 1):
			if b[i] < a[i]:
				t = 0
				break
	if t == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	d = {}
	flag = 0
	for i in range(n):
		if arr[i] == brr[i]:
			if arr[i] in d:
				d[arr[i]] += 1
			else:
				d[arr[i]] = 1
		elif brr[i] - arr[i] > 0:
			if 1 not in d:
				flag = 1
				break
			elif arr[i] in d:
				d[arr[i]] += 1
			else:
				d[arr[i]] = 1
		elif -1 not in d:
			flag = 1
			break
		elif arr[i] in d:
			d[arr[i]] += 1
		else:
			d[arr[i]] = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


def f():
	n = int(input())
	A = [int(s) for s in input().split()]
	B = [int(s) for s in input().split()]
	plus = 0
	minus = 0
	for i in range(n):
		if B[i] > A[i]:
			if not plus:
				print('NO')
				return
		if B[i] < A[i]:
			if not minus:
				print('NO')
				return
		if A[i] == 1:
			plus = 1
		if A[i] == -1:
			minus = 1
	print('YES')
for t in range(int(input())):
	f()


t = int(input())
for i in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	one_num = 0
	min_num = 0
	for j in range(N):
		if a[j] == 1:
			one_num += 1
		elif a[j] == -1:
			min_num += 1
	flag = True
	for j in range(N):
		k = N - 1 - j
		if a[k] == 1:
			one_num -= 1
		elif a[k] == -1:
			min_num -= 1
		if a[k] < b[k]:
			if one_num == 0:
				flag = False
				break
		elif a[k] > b[k]:
			if min_num == 0:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	st = set([0])
	can = True
	for i in range(n):
		x = 0 if a[i] == b[i] else 1 if a[i] < b[i] else -1
		if x not in st:
			can = False
			break
		st.add(a[i])
	if can:
		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()))
	r = 1
	if a[0] != b[0]:
		print('NO')
	else:
		vis = {a[0]}
		for i in range(1, n):
			if a[i] < b[i] and 1 not in vis:
				print('NO')
				r = 0
				break
			elif a[i] > b[i] and -1 not in vis:
				r = 0
				print('NO')
				break
			vis.add(a[i])
		if r:
			print('YES')


import sys
from collections import defaultdict
from copy import copy
R = lambda t=int: t(input())
RL = lambda t=int: [t(x) for x in input().split()]
RLL = lambda n, t=int: [RL(t) for _ in range(n)]

def solve():
	n = R()
	A = RL()
	B = RL()
	if A[0] != B[0]:
		print('NO')
		return
	m = p = 0
	m = A[0] < 0
	p = A[0] > 0
	for i in range(1, n):
		if B[i] > A[i] and (not p):
			print('NO')
			return
		if B[i] < A[i] and (not m):
			print('NO')
			return
		m |= A[i] < 0
		p |= A[i] > 0
		if m and p:
			print('YES')
			return
	print('YES')
T = R()
for _ in range(T):
	solve()


import sys
input = sys.stdin.readline
for i in ' ' * int(input()):
	n = int(input())
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	same = True
	big = False
	small = False
	breaked = False
	for j in range(n):
		if L1[j] < L2[j]:
			if not big:
				breaked = True
				break
		if L1[j] > L2[j]:
			if not small:
				breaked = True
				break
		if L1[j] == 1:
			big = True
		if L1[j] == -1:
			small = True
	print(['YES', 'NO'][breaked])


import sys
input = sys.stdin.readline
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	canIncrease = False
	canDecrease = False
	ans = 'YES'
	for j in range(n):
		if a[j] > b[j]:
			if canDecrease == False:
				ans = 'NO'
		elif a[j] < b[j]:
			if canIncrease == False:
				ans = 'NO'
		if a[j] == -1:
			canDecrease = True
		elif a[j] == 1:
			canIncrease = True
	print(ans)


t = int(input())
re = []
for aaa in range(t):
	n = int(input())
	a = [int(aaa) for aaa in input().split()]
	b = [int(aaaa) for aaaa in input().split()]
	pa = 0
	na = 0
	q = 1
	for i in range(n):
		a1 = a[i]
		if a1 > 0:
			pa += 1
		elif a1 < 0:
			na += 1
	for i in range(n):
		e = -i - 1
		g = b[e]
		r = a[e]
		m = g - r
		if m < 0:
			if na > 0:
				if r > 0:
					pa -= 1
				elif r < 0:
					if na == 1:
						q = 0
						break
					else:
						na -= 1
			else:
				q = 0
				break
		elif m > 0:
			if pa > 0:
				if r > 0:
					if pa == 1:
						q = 0
						break
					else:
						pa -= 1
				elif r < 0:
					na -= 1
			else:
				q = 0
				break
		elif r > 0:
			pa -= 1
		elif r < 0:
			na -= 1
	if q == 0:
		re.append('NO')
	else:
		re.append('YES')
for i in re:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	left = set()
	res = 'YES'
	for i in range(n):
		if b[i] != a[i]:
			if b[i] > a[i] and 1 not in left:
				res = 'NO'
				break
			elif b[i] < a[i] and -1 not in left:
				res = 'NO'
				break
		left.add(a[i])
	print(res)


t = int(input())
for test in range(t):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	f_pos = False
	f_neg = False
	for i in range(n):
		if f_pos and f_neg:
			print('YES')
			break
		elif arr1[i] == arr2[i]:
			if arr1[i] == 1:
				f_pos = True
			if arr1[i] == -1:
				f_neg = True
		elif arr1[i] > arr2[i]:
			if f_neg:
				if arr1[i] == 1:
					f_pos = True
			else:
				print('NO')
				break
		elif f_pos:
			if arr1[i] == -1:
				f_neg = True
		else:
			print('NO')
			break
		if i == n - 1:
			print('YES')


from sys import stdin, stdout
import math
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d = {}
	f = 1
	for i in range(n):
		d[a[i]] = d.get(a[i], 0) + 1
	for i in range(n - 1, -1, -1):
		v = a[i]
		d[v] -= 1
		if b[i] > v and d.get(1, 0) <= 0:
			f = 0
			break
		if b[i] < v and d.get(-1, 0) <= 0:
			f = 0
			break
	print('YES' if f else 'NO')


t = int(input())
for rep in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	f = 0
	for i in range(n):
		if b[i] > a[i] and 1 not in d:
			f = 1
			print('NO')
			break
		elif b[i] < a[i] and -1 not in d:
			f = 1
			print('NO')
			break
		elif a[i] not in d:
			d[a[i]] = 0
	if f == 0:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = [False] * 3
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	impossible = False
	for i in range(n):
		if b[i] < a[i] and (not s[0]) or (b[i] > a[i] and (not s[2])):
			impossible = True
			break
		s[a[i] + 1] = True
	print('NO' if impossible else 'YES')


t = int(input())
for T in range(t):
	n = int(input())
	arr_a = list(map(int, input().split()))
	arr_b = list(map(int, input().split()))
	ans = 'YES'
	if arr_a[0] != arr_b[0]:
		ans = 'NO'
	else:
		neg = False
		pos = False
		if arr_a[0] == 1:
			pos = True
		elif arr_a[0] == -1:
			neg = True
		for i in range(1, n):
			if arr_a[i] != arr_b[i]:
				if arr_a[i] > arr_b[i]:
					if neg == False:
						ans = 'NO'
						break
				elif arr_a[i] < arr_b[i]:
					if pos == False:
						ans = 'NO'
						break
			if arr_a[i] == -1:
				neg = True
			if arr_a[i] == 1:
				pos = True
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr_a = list(map(int, input().split()))
	arr_b = list(map(int, input().split()))
	seen1 = False
	seen_neg1 = False
	possible = True
	for i in range(n):
		if arr_b[i] > arr_a[i] and (not seen1):
			possible = False
			print('NO')
			break
		if arr_b[i] < arr_a[i] and (not seen_neg1):
			possible = False
			print('NO')
			break
		if arr_a[i] == 1:
			seen1 = True
		if arr_a[i] == -1:
			seen_neg1 = True
	if possible:
		print('YES')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if A[0] != B[0]:
		print('NO')
		continue
	C = [set() for i in range(n)]
	S = set()
	for i in range(n):
		a = A[i]
		S.add(a)
		C[i] |= S
	for i in range(n - 1, 0, -1):
		if B[i] > A[i] and (not 1 in C[i - 1]):
			print('NO')
			break
		if B[i] < A[i] and (not -1 in C[i - 1]):
			print('NO')
			break
	else:
		print('YES')


t = int(input())
al = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	f = 0
	z = 0
	for j in range(n):
		if a[j] == 0:
			z += 1
		elif a[j] == 1:
			s += 1
		else:
			f += 1
	ans = 'YES'
	for j in range(n - 1, -1, -1):
		if a[j] == 0:
			z -= 0
		elif a[j] == 1:
			s -= 1
		else:
			f -= 1
		if b[j] > a[j]:
			if s == 0:
				ans = 'NO'
				break
		elif b[j] < a[j]:
			if f == 0:
				ans = 'NO'
	al.append(ans)
for i in al:
	print(i)


testCases = int(input())

def convertArrayToInt(A):
	for i in range(0, len(A), 1):
		A[i] = int(A[i])
	return A

def canBeConverted(A, B):
	for i in range(len(A)):
		if A[i] != B[i]:
			diff = B[i] - A[i]
			flag = 0
			for x in range(0, i, 1):
				if A[x] != 0 and diff * A[x] > 0 and (diff % A[x] == 0):
					flag = 1
					break
			if flag == 0:
				return 'NO'
	return 'YES'
while testCases:
	length = int(input())
	A = input().split()
	B = input().split()
	A = convertArrayToInt(A)
	B = convertArrayToInt(B)
	ans = canBeConverted(A, B)
	print(ans)
	testCases -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	a_cum = []
	a_cum_ar = [0] * 2
	for i in range(n):
		if a[i] == 1:
			a_cum_ar[0] += 1
		elif a[i] == -1:
			a_cum_ar[1] += 1
		a_cum.append(tuple(a_cum_ar))
	flag = True
	for i in range(n - 1, 0, -1):
		if a[i] > b[i]:
			if a_cum[i - 1][1] == 0:
				print('NO')
				flag = False
				break
		elif a[i] < b[i]:
			if a_cum[i - 1][0] == 0:
				print('NO')
				flag = False
				break
	if flag:
		print('YES')


import sys
from itertools import accumulate

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	B = LIST()
	can_add = False
	can_sub = False
	for i in range(N):
		if A[i] < B[i] and (not can_add):
			NO()
			break
		if A[i] > B[i] and (not can_sub):
			NO()
			break
		if A[i] > 0:
			can_add = True
		if A[i] < 0:
			can_sub = True
	else:
		YES()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = set()
	x = 'YES'
	for i in range(n):
		if b[i] > a[i] and 1 not in c or (a[i] > b[i] and -1 not in c):
			x = 'NO'
			break
		c.add(a[i])
	print(x)


t = int(input())
while t != 0:
	n = int(input())
	arrA = list(map(int, input().split()))
	arrB = list(map(int, input().split()))
	result = 'YES'
	if arrA[0] != arrB[0]:
		result = 'NO'
	else:
		minIndexOne = -1
		minIndexMinusOne = -1
		for i in range(n):
			if arrA[i] == 1:
				minIndexOne = i
				break
		for i in range(n):
			if arrA[i] == -1:
				minIndexMinusOne = i
				break
		for i in range(1, n):
			if arrB[i] > arrA[i] and (minIndexOne == -1 or minIndexOne >= i):
				result = 'NO'
				break
			if arrB[i] < arrA[i] and (minIndexMinusOne == -1 or minIndexMinusOne >= i):
				result = 'NO'
				break
	print(result)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	flag = 0
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	lis = []
	for i in range(n):
		lis.append(b[i] - a[i])
	if lis[0] != 0:
		flag = 1
	i = 1
	dic = {}
	try:
		dic[-1] = a.index(-1)
	except:
		dic[-1] = n + 1
	try:
		dic[1] = a.index(1)
	except:
		dic[1] = n + 1
	while flag != 1 and i < n:
		if lis[i] > 0:
			if dic[1] < i:
				pass
			else:
				flag = 1
		elif lis[i] < 0:
			if dic[-1] < i:
				pass
			else:
				flag = 1
		i += 1
	print('NO' if flag else 'YES')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	b = [int(item) for item in input().split()]
	can_increase = False
	can_decrease = False
	ok = True
	for (an, bn) in zip(a, b):
		if an > bn and (not can_decrease):
			ok = False
			break
		if an < bn and (not can_increase):
			ok = False
			break
		if an == 1:
			can_increase = True
		if an == -1:
			can_decrease = True
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	opts = set()
	ans = 'YES'
	for i in range(n):
		if b[i] > a[i] and 1 not in opts:
			ans = 'NO'
		if b[i] < a[i] and -1 not in opts:
			ans = 'NO'
		opts.add(a[i])
	print(ans)


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()]
	first_i = None
	first_p = None
	first_n = None
	for i in range(n):
		if a[i] == -1 or a[i] == 1:
			if first_i is None:
				first_i = i
			if a[i] == 1:
				if first_p is None:
					first_p = i
			if a[i] == -1:
				if first_n is None:
					first_n = i
	if first_i is None:
		done = False
		for i in range(n):
			if b[i] != 0:
				print('NO')
				done = True
				break
		if not done:
			print('YES')
	else:
		done = False
		for i in range(first_i):
			if b[i] != 0:
				print('NO')
				done = True
				break
		if not done:
			if a[first_i] != b[first_i]:
				print('NO')
				done = True
			if not done:
				if first_p is None:
					first_p = float('inf')
				if first_n is None:
					first_n = float('inf')
				for i in range(first_i + 1, n):
					if b[i] > a[i]:
						if first_p >= i:
							print('NO')
							done = True
							break
					if b[i] < a[i]:
						if first_n >= i:
							print('NO')
							done = True
							break
				if not done:
					print('YES')


from sys import stdin, stdout
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x * (x + 1) // 2
I = lambda x: 1 + 2 * x
R = lambda : stdin.readline()
Ri = lambda x: map(int, x.split())
Rs = lambda x: map(str, x.split())
Rf = lambda x: map(float, x.split())
MaxN = int(100000.0) + 10

def main():
	for x in stdin:
		t = int(x)
		for c in range(t):
			n = int(R())
			A = list(Ri(R()))
			B = list(Ri(R()))
			(C, D) = ([], [])
			(c, d) = (0, 0)
			for x in A:
				if x > 0:
					c = 1
				if x < 0:
					d = 1
				C.append(c)
				D.append(d)
			sw = 1
			if A[0] == B[0]:
				for i in range(n - 1, 0, -1):
					if sw == 0:
						break
					if A[i] == B[i]:
						continue
					if A[i] < B[i]:
						if C[i - 1] == 0:
							sw = 0
					elif D[i - 1] == 0:
						sw = 0
			else:
				sw = 0
			if sw:
				Pi('YES')
			else:
				Pi('NO')
main()


test = int(input())
while test:
	length = int(input())
	a = [int(n) for n in input().split()]
	b = [int(n) for n in input().split()]
	t = True
	i = 1
	freq = [0] * 3
	if a[0] == b[0]:
		freq[a[0]] = 1
		while t and i < length:
			if b[i] > a[i] and freq[1] == 0 or (b[i] < a[i] and freq[-1] == 0):
				t = False
			freq[a[i]] = 1
			i += 1
	else:
		t = False
	if t:
		print('YES')
	else:
		print('NO')
	test -= 1


from sys import stdin
input = stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(j) for j in input().split()]
	B = [int(j) for j in input().split()]
	avail = set()
	for j in range(n):
		if A[j] != B[j]:
			pk = B[j] - A[j]
			if pk > 0:
				if 1 in avail:
					pass
				else:
					break
			elif pk < 0:
				if -1 in avail:
					pass
				else:
					break
		avail.add(A[j])
	else:
		print('YES')
		continue
	print('NO')


a = int(input())
for i in range(0, a):
	b = int(input())
	arr = list(map(int, input().split()))
	target = list(map(int, input().split()))
	one = -1
	if 1 in arr:
		one = arr.index(1)
	mone = -1
	final = 0
	if -1 in arr:
		mone = arr.index(-1)
	for i in range(0, len(arr)):
		if target[i] - arr[i] < 0:
			if mone >= i or mone == -1:
				final = 1
				break
		if target[i] - arr[i] > 0:
			if one >= i or one == -1:
				final = 1
				break
	if final == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	try:
		i1 = a.index(-1)
	except:
		i1 = n
	try:
		i2 = a.index(1)
	except:
		i2 = n
	for i in range(n):
		if a[i] < b[i]:
			if i2 >= i:
				print('NO')
				break
		if a[i] > b[i]:
			if i1 >= i:
				print('NO')
				break
	else:
		print('YES')


from math import *
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	cnt1 = 0
	cnt0 = 0
	cntotr = 0
	f = True
	for i in range(n):
		if a[i] > b[i]:
			if cntotr == 0:
				f = False
				break
		if a[i] < b[i]:
			if cnt1 == 0:
				f = False
				break
		if a[i] == 0:
			cnt0 += 1
		elif a[i] == 1:
			cnt1 += 1
		else:
			cntotr += 1
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	ai = list(map(int, input().split()))
	bi = list(map(int, input().split()))
	flagp = 0
	flagn = 0
	ans = ['YES', 'NO']
	for i in range(n):
		if flagp and flagn:
			break
		if flagp == 0 and bi[i] > ai[i]:
			ans[0] = ans[1]
			break
		if flagn == 0 and bi[i] < ai[i]:
			ans[0] = ans[1]
			break
		if ai[i] == 1:
			flagp = 1
		elif ai[i] == -1:
			flagn = 1
	print(ans[0])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

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

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = li()
		x = 0
		y = 0
		p = [0] * (n + 5)
		q = [0] * (n + 5)
		if a[0] == 1:
			p[0] = 1
		if a[0] == -1:
			q[0] = 1
		for i in range(1, n):
			p[i] = p[i - 1]
			q[i] = q[i - 1]
			if a[i] == 1:
				p[i] = 1
			if a[i] == -1:
				q[i] = 1
		if True:
			ans = 1
			for i in range(n - 1, 0, -1):
				if b[i] > a[i]:
					if p[i - 1] == 1:
						b[i] = a[i]
					else:
						ans = 0
						break
				if b[i] < a[i]:
					if q[i - 1] == 1:
						b[i] = a[i]
					else:
						ans = 0
						break
		if True:
			if ans == 0:
				print('NO')
				continue
			if a == b:
				print('YES')
			else:
				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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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

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

def string_list():
	return list(input())
for t in range(int(input())):
	n = int(input())
	a = list_input()
	b = list_input()
	flag = False
	indx_1 = indx_minus = -1
	for i in range(n):
		if a[i] == b[i]:
			if a[i] == 1:
				indx_1 = i
			elif a[i] == -1:
				indx_minus = i
		elif b[i] < a[i]:
			if indx_minus == -1:
				flag = True
				break
			elif a[i] == 1:
				indx_1 = i
		elif b[i] > a[i]:
			if indx_1 == -1:
				flag = True
				break
			elif a[i] == -1:
				indx_minus = i
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for k in range(t):
	n = int(input())
	hasSolve = True
	hasP = False
	hasM = False
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		hasSolve = False
	else:
		i = 0
		while not (hasM and hasP) and n - i != 1:
			i += 1
			if a[i] == b[i]:
				continue
			elif a[i] < b[i] and 1 in a[:i]:
				hasP = True
				continue
			elif a[i] > b[i] and -1 in a[:i]:
				hasM = True
				continue
			else:
				hasSolve = False
				break
	if hasSolve:
		print('YES')
	else:
		print('NO')


import sys
readline = sys.stdin.readline
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))

def solve():
	n = ni()
	a = nl() + [1, -1]
	b = nl()
	p = a.index(1)
	m = a.index(-1)
	for i in range(n - 1, -1, -1):
		if a[i] < b[i] and p >= i or (a[i] > b[i] and m >= i):
			print('NO')
			return
	print('YES')
	return
T = ni()
for _ in range(T):
	solve()


c = int(input())
for w in range(c):
	input()
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	flagUp = 10000000
	flagDown = 10000000
	for i in range(len(a)):
		if a[i] == 1:
			flagUp = i
			break
	for i in range(len(a)):
		if a[i] == -1:
			flagDown = i
			break
	resp = True
	for i in range(len(b)):
		if a[i] != b[i]:
			if b[i] > a[i]:
				resp = resp and flagUp < i
			else:
				resp = resp and flagDown < i
	if resp:
		print('YES')
	else:
		print('NO')


import sys

def count(a, b, n):
	if a[0] != b[0]:
		return 'NO'
	else:
		pos = {}
		if 1 in a:
			pos[1] = a.index(1)
		else:
			pos[1] = sys.maxsize
		if -1 in a:
			pos[-1] = a.index(-1)
		else:
			pos[-1] = sys.maxsize
		for i in range(1, n):
			if a[i] > b[i]:
				if pos[-1] >= i:
					return 'NO'
			elif a[i] < b[i]:
				if pos[1] >= i:
					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(count(a, b, n))


def testCase(a, b):
	d = {1: 0, -1: 0, 0: 0}
	if b[0] != a[0]:
		return 'NO'
	d[a[0]] += 1
	for i in range(1, len(a)):
		if b[i] == a[i]:
			d[a[i]] += 1
			continue
		bm = b[i]
		if bm < 0:
			if not d[-1] > 0:
				return 'NO'
		elif bm > 0:
			if not d[1] > 0:
				return 'NO'
		elif bm == 0:
			if not (d[1] > 0 and a[i] == -1 or (d[-1] > 0 and a[i] == 1)):
				return 'NO'
		d[a[i]] += 1
	return 'YES'
t = int(input().strip())
for i in range(t):
	lines = int(input().strip())
	a = input().strip().split(' ')
	a = [int(i) for i in a]
	b = input().strip().split(' ')
	b = [int(i) for i in b]
	print(testCase(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()))
	ans = 'YES'
	seen1 = False
	seen_1 = False
	for j in range(len(a)):
		if a[j] != b[j]:
			if b[j] - a[j] >= 1:
				if seen1:
					ans = 'YES'
					if a[j] < 0:
						seen_1 = True
				else:
					ans = 'NO'
					break
			elif b[j] - a[j] < 0:
				if seen_1:
					ans = 'YES'
					if a[j] > 0:
						seen1 = True
				else:
					ans = 'NO'
					break
		elif a[j] < 0:
			seen_1 = True
		elif a[j] > 0:
			seen1 = True
	print(ans)


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = [0, 0, 0]
	flag = 0
	for i in range(n):
		if A[i] > B[i]:
			if C[0] == 0:
				flag = 1
				break
		elif A[i] < B[i]:
			if C[2] == 0:
				flag = 1
				break
		C[A[i] + 1] = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	se = set()
	valid = True
	for i in range(n):
		if a[i] != b[i]:
			if b[i] - a[i] > 0:
				val = 1
			else:
				val = -1
			if val not in se:
				valid = False
				break
		if a[i] == 1:
			se.add(1)
		elif a[i] == -1:
			se.add(-1)
		if len(se) == 2:
			break
	if valid:
		print('YES')
	else:
		print('NO')


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

def ii():
	return int(input())
testcases = int(input())
for t in range(testcases):
	n = ii()
	a = li()
	b = li()
	flag = True
	max_a = a[0]
	min_a = a[0]
	if a[0] < b[0]:
		flag = False
	if a[0] > b[0]:
		flag = False
	for i in range(1, n):
		if a[i] < b[i] and max_a <= 0:
			flag = False
		elif a[i] > b[i] and min_a >= 0:
			flag = False
		max_a = max(max_a, a[i])
		min_a = min(min_a, a[i])
	print('YES' if flag else '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()]
	left_m = 1000000000.0
	left_p = 1000000000.0
	for i in range(n):
		if b[i] - a[i] < 0:
			left_m = min(left_m, i)
		if b[i] - a[i] > 0:
			left_p = min(left_p, i)
	left_a_m = 1000000000.0 - 1
	left_a_p = 1000000000.0 - 1
	for i in range(n):
		if a[i] < 0:
			left_a_m = min(left_a_m, i)
		if a[i] > 0:
			left_a_p = min(left_a_p, i)
	if left_a_m < left_m and left_a_p < left_p:
		print('YES')
	else:
		print('NO')


import io
import os
import sys
import math
import heapq
import bisect
import random
import string
import decimal
import functools
import fractions
import itertools
import collections
from sys import stdin, stdout
from io import BytesIO, IOBase
from math import gcd, floor, sqrt, log, factorial
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict, OrderedDict, namedtuple, UserDict, UserList, UserString
MOD = 1000000007
sys.setrecursionlimit(100000000)
BUFSIZE = 8192
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()]
	seen = set()
	ans = 'YES'
	for (i, j) in zip(a, b):
		if i == j:
			seen.add(i)
			continue
		elif j < i and -1 not in seen:
			ans = 'NO'
		elif j > i and 1 not in seen:
			ans = 'NO'
		seen.add(i)
	print(ans)


t = int(input())
for ii in range(t):
	n = int(input())
	a = []
	b = []
	c = input().split()
	for i in range(n):
		tp = int(c[i])
		a.append(tp)
	c = input().split()
	for i in range(n):
		tp = int(c[i])
		b.append(tp)
	up = down = False
	ans = True
	for (i, j) in zip(a, b):
		if i < j:
			if not up:
				ans = False
		elif i > j:
			if not down:
				ans = False
		if i == 1:
			up = True
		if i == -1:
			down = -1
	if ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	try:
		one = a.index(1) - n
	except:
		one = None
	try:
		minu = a.index(-1) - n
	except:
		minu = None
	flag = 1
	for i in range(-1, -n - 1, -1):
		if b[i] - a[i] > 0:
			if one == None or one >= i:
				flag = 0
				break
		elif b[i] - a[i] < 0:
			if minu == None or minu >= i:
				flag = 0
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		i = 0
		(ax, ay) = (0, 0)
		while i < n:
			if a[i] == b[i]:
				if a[i] == 1:
					ax = 1
				elif a[i] == -1:
					ay = 1
				i += 1
			elif a[i] < b[i] and ax == 1:
				if a[i] == 1:
					ax = 1
				elif a[i] == -1:
					ay = 1
				i += 1
			elif a[i] > b[i] and ay == 1:
				if a[i] == 1:
					ax = 1
				elif a[i] == -1:
					ay = 1
				i += 1
			else:
				i = -1
				print('NO')
				break
		if i == n:
			print('YES')
main()


import sys
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(ipnut())):
	n = int(ipnut())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f1 = False
	f2 = False
	f = True
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] > b[i]:
			if not f2:
				f = False
				break
		elif not f1:
			f = False
			break
		if a[i] == 1:
			f1 = True
		elif a[i] == -1:
			f2 = True
	if f:
		print('YES')
	else:
		print('NO')


def cal(n, a, b, a1, aminus):
	for i in range(n):
		if a[i] < b[i]:
			if a1 >= i or a1 == -1:
				return False
		elif a[i] > b[i]:
			if aminus >= i or aminus == -1:
				return False
	return True
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	try:
		a1 = a.index(1)
	except ValueError:
		a1 = -1
	try:
		aminus = a.index(-1)
	except ValueError:
		aminus = -1
	val = cal(n, a, b, a1, aminus)
	if val == True:
		print('YES')
	else:
		print('NO')


def checker(n, lst1, lst2):
	(s, answer) = (set(), 'YES')
	for i in range(n):
		if lst2[i] > lst1[i] and 1 not in s or (lst2[i] < lst1[i] and -1 not in s):
			answer = 'NO'
			break
		s.add(lst1[i])
	return answer
for _ in range(int(input())):
	m = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	print(checker(m, a, b))


def check(a, b):
	temp = {}
	val = True
	for i in range(len(a)):
		if not a[i] == b[i]:
			if a[i] > b[i] and (not -1 in temp) or (a[i] < b[i] and (not 1 in temp)):
				val = False
				break
			else:
				temp[a[i]] = 1
		else:
			temp[a[i]] = 1
		if 1 in temp and -1 in temp:
			break
	if val:
		print('YES')
	else:
		print('NO')
t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	check(a, b)
	i = i + 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	br = 0
	ha = [0] * 3
	for i in range(n):
		if a[i] != b[i]:
			br = 1
			break
		else:
			ha[a[i] + 1] += 1
	if br == 0:
		print('YES')
	else:
		br = 0
		while i < n:
			if a[i] < b[i]:
				if ha[2] <= 0:
					br = 1
					break
				else:
					ha[a[i] + 1] += 1
			elif a[i] > b[i]:
				if ha[0] <= 0:
					br = 1
					break
				else:
					ha[a[i] + 1] += 1
			i += 1
		if br == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	temp = [0, 0, 0]
	pref = []
	for i in range(n):
		if a[i] == -1:
			temp[0] += 1
		elif a[i] == 0:
			temp[1] += 1
		else:
			temp[2] += 1
		pref += [temp[:]]
	if a[0] != b[0]:
		print('NO')
		continue
	flag = 0
	for i in range(n - 1, 0, -1):
		if a[i] > b[i] and pref[i - 1][0] == 0:
			flag = 1
			break
		if a[i] < b[i] and pref[i - 1][2] == 0:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


n = int(input())
k = []
for e in range(n):
	a = int(input())
	t = list(map(int, input().rstrip().split()))
	m = list(map(int, input().rstrip().split()))
	b = 0
	flag = 0
	fla = 0
	minus = 0
	plus = 0
	while b < a:
		if t[b] == m[b] and b == 0 and (t[b] == 0):
			b = b + 1
			fla = 1
		elif t[b] == m[b] and fla == 1 and (t[b] == 0):
			b = b + 1
		elif t[b] == m[b] and fla == 1 and (t[b] != 0):
			if t[b] == 1:
				plus = 1
				fla = 0
			else:
				minus = 1
				fla = 0
			b = b + 1
		elif t[b] != m[b] and fla == 1:
			flag = 1
			break
		elif t[b] != m[b] and b == 0:
			flag = 1
			break
		elif t[b] == m[b] and b == 0:
			if t[b] == -1:
				minus = 1
				b = b + 1
			else:
				plus = 1
				b = b + 1
		elif t[b] != m[b] and plus == 1 and (minus == 1):
			flag = 2
			break
		elif plus == 1 and m[b] < t[b] or (minus == 1 and m[b] > t[b]):
			flag = 1
			break
		elif (plus == 1 and m[b] >= t[b]) and t[b] == -1:
			minus = 1
			b = b + 1
		elif (minus == 1 and m[b] <= t[b]) and t[b] == 1:
			plus = 1
			b = b + 1
		else:
			b = b + 1
	if flag == 0 or flag == 2:
		k.append('YES')
	else:
		k.append('NO')
for v in range(n):
	print(k[v])


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	ans = True
	haveM = False
	haveP = False
	for i in range(n):
		if b[i] > a[i] and (not haveP):
			ans = False
		if b[i] < a[i] and (not haveM):
			ans = False
		if a[i] > 0:
			haveP = True
		if a[i] < 0:
			haveM = True
	if ans:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	b = input().split()
	y = set()
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(1, n):
			y.add(a[i - 1])
			if a[i] < b[i] and 1 in y:
				continue
			elif a[i] > b[i] and -1 in y:
				continue
			elif a[i] == b[i]:
				continue
			else:
				print('NO')
				break
		else:
			print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	mode = [0] * n
	mode1 = False
	mode2 = False
	for i in range(1, n):
		if a[i - 1] == 0:
			pass
		elif a[i - 1] == 1:
			mode1 = True
		else:
			mode2 = True
		if mode1 and mode2:
			mode[i] = 3
		elif mode1:
			mode[i] = 1
		elif mode2:
			mode[i] = 2
		else:
			pass
	ans = True
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] < b[i]:
			if mode[i] == 1 or mode[i] == 3:
				pass
			else:
				ans = False
				break
		elif mode[i] == 2 or mode[i] == 3:
			pass
		else:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


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


from collections import defaultdict as df
t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	posi = 0
	negi = 0
	flag = 0
	if a[0] != b[0]:
		print('NO')
		continue
	if a[0] == 1:
		posi = 1
	if a[0] == -1:
		negi = 1
	for i in range(1, n):
		if a[i] == b[i]:
			if a[i] == 1:
				posi = 1
			if a[i] == -1:
				negi = 1
		elif b[i] > a[i]:
			if posi:
				pass
			else:
				flag = 1
				break
			if a[i] == 1:
				posi = 1
			if a[i] == -1:
				negi = 1
		else:
			if negi:
				pass
			else:
				flag = 1
				break
			if a[i] == 1:
				posi = 1
			if a[i] == -1:
				negi = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


def possible(a, b):
	s = set()
	for (aa, bb) in zip(a, b):
		if bb > aa and 1 not in s:
			return False
		if bb < aa and -1 not in s:
			return False
		s.add(aa)
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print('YES' if possible(a, b) else 'NO')


T = int(input())
for t in range(T):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	s = b[0] == a[0]
	if 1 in a:
		p = a.index(1)
		s = s and all((b[i] <= a[i] for i in range(p + 1)))
	else:
		s = s and all((b[i] <= a[i] for i in range(n)))
	if -1 in a:
		q = a.index(-1)
		s = s and all((b[i] >= a[i] for i in range(q + 1)))
	else:
		s = s and all((b[i] >= a[i] for i in range(n)))
	print('YES' if s else 'NO')


def makeEqToB(a, b):
	if a[0] == b[0]:
		one = -1
		minusone = 1
		if a[0] == 1:
			one = 1
		elif a[0] == -1:
			minusone = -1
		for i in range(1, len(a)):
			if a[i] > b[i] and minusone != -1:
				print('NO')
				return
			if a[i] < b[i] and one != 1:
				print('NO')
				return
			if a[i] == -1:
				minusone = -1
			if a[i] == 1:
				one = 1
	else:
		print('NO')
		return
	print('YES')

def main():
	t = int(input())
	for x in range(t):
		input()
		a = input().split()
		a = [int(i) for i in a]
		b = input().split()
		b = [int(i) for i in b]
		makeEqToB(a, b)
main()


import sys, io, os
input = sys.stdin.readline
inputt = lambda : range(int(input()))
inputn = lambda n=1: range(n)
inputi = lambda : map(int, input().split())
inputl = lambda : list(inputi())
from math import *
from heapq import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
from builtins import *
MOD = 10 ** 9 + 7

def main():
	for _ in inputt():
		(n,) = inputi()
		(A, B) = (inputl(), inputl())
		(p, np) = (False, False)
		t = False
		for i in range(n):
			if B[i] > A[i]:
				if not p:
					print('NO')
					break
			elif B[i] < A[i]:
				if not np:
					print('NO')
					break
			if A[i] == 1:
				p = True
			elif A[i] == -1:
				np = True
		else:
			print('YES')
main()


for _ in range(int(input())):
	x = int(input())
	li = list(map(int, input().split()))
	li1 = list(map(int, input().split()))
	li2 = set()
	if li[0] != li1[0]:
		print('NO')
		continue
	else:
		li2.add(li[0])
	b = True
	for i in range(1, x):
		if li[i] < li1[i]:
			if 1 not in li2:
				b = False
				break
		elif li[i] > li1[i]:
			if -1 not in li2:
				b = False
				break
		if li[i] not in li2:
			li2.add(li[i])
	print('YES' if b else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	positive = False
	negative = False
	passs = 'YES'
	for i in range(n):
		if a[i] < b[i] and positive == False:
			passs = 'NO'
		if a[i] > b[i] and negative == False:
			passs = 'NO'
		if a[i] == 1:
			positive = True
		if a[i] == -1:
			negative = True
	print(passs)


import sys
input = lambda : sys.stdin.readline().rstrip()

def zap():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = []
	for i in range(n):
		if a[i] < b[i] and 1 not in s or (a[i] > b[i] and -1 not in s):
			return 'NO'
		s.append(a[i])
	return 'YES'
for i in range(int(input())):
	print(zap())


TEST = False

def solve(a, b):
	res = ['NO', 'YES']
	prev = set()
	if a[0] != b[0]:
		return res[0]
	for (ai, bi) in zip(a, b):
		if bi > ai and 1 not in prev:
			return res[0]
		elif bi < ai and -1 not in prev:
			return res[0]
		else:
			prev.add(ai)
	return res[1]
s_in = '\n5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 0\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\n1 1 -1 1 -1\n'
s_out = '\nYES\nNO\nYES\nYES\nNO\n'
l_in = list(reversed(s_in.split('\n')[1:-1]))
l_out = list(reversed(s_out.split('\n')[1:-1]))
if TEST:
	tc = []
	q = int(l_in.pop())
	for qi in range(q):
		n = int(l_in.pop())
		a = list(map(int, l_in.pop().split()))
		b = list(map(int, l_in.pop().split()))
		sol = l_out.pop().strip()
		tc.append([a, b, sol])
	print('\n*** tc ***')
	for test in tc:
		print(test)
	print('*** tc ***\n')
	for (a, b, sol) in tc:
		res = solve(a, b)
		print(res, sol, res == sol)
else:
	q = int(input())
	for qi in range(q):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		res = solve(a, b)
		print(f'{res}')


t = int(input())
for _ in range(t):
	N = int(input())
	A = input().split()
	A = [int(ai) for ai in A]
	B = input().split()
	B = [int(bi) for bi in B]
	(p, n) = (False, False)
	poss = True
	for i in range(N):
		if B[i] > A[i] and (not p):
			poss = False
			break
		if B[i] < A[i] and (not n):
			poss = False
			break
		if A[i] == 1:
			p = True
		if A[i] == -1:
			n = True
	if poss:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split(' ')
	a = [int(x) for x in a]
	if a.count(1) != 0:
		f1 = a.index(1)
	else:
		f1 = 99999999
	if a.count(-1) != 0:
		fn1 = a.index(-1)
	else:
		fn1 = 9999999
	b = input().split(' ')
	b = [int(x) for x in b]
	possible = 'YES'
	for i in range(n):
		if a[i] > b[i]:
			if fn1 >= i:
				possible = 'NO'
		elif a[i] < b[i]:
			if f1 >= i:
				possible = 'NO'
	print(possible)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(x, y) = (n - 1, n - 1)
	for i in range(n):
		if a[i] == 1:
			x = i
			break
	for i in range(n):
		if a[i] == -1:
			y = i
			break
	flag = 0
	for i in range(x + 1):
		if b[i] > a[i]:
			print('NO')
			flag = 1
			break
	if flag == 0:
		for i in range(y + 1):
			if b[i] < a[i]:
				print('NO')
				flag = 1
				break
	if flag == 0:
		print('YES')


import sys
from sys import stdin, stdout

def R():
	return map(int, stdin.readline().strip().split())
ans = []
for h in range(int(stdin.readline())):
	n = list(R())[0]
	A = list(R())
	B = list(R())
	flag1 = 0
	flag2 = 0
	for i in range(n):
		if A[i] < B[i]:
			if flag1 == 0:
				ans.append('NO')
				break
		elif A[i] > B[i]:
			if flag2 == 0:
				ans.append('NO')
				break
		if A[i] == 1:
			flag1 = 1
		if A[i] == -1:
			flag2 = 1
	else:
		ans.append('YES')
stdout.write('\n'.join(ans))


t = int(input())
for tt in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	flag = True
	x = 0
	y = 0
	for i in range(len(arr)):
		if arr[i] < brr[i] and y == 0:
			flag = False
			break
		if arr[i] > brr[i] and x == 0:
			flag = False
			break
		if arr[i] == 1:
			y = 1
		if arr[i] == -1:
			x = 1
	if flag:
		print('YES')
	else:
		print('NO')


def ntvdm():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		exists = [[], [], []]
		for (i, k) in enumerate(a):
			exists[k].append(i)
		flag = True
		for (aa, bb) in zip(reversed(a), reversed(b)):
			exists[aa].pop()
			if aa < bb and (not exists[1]):
				print('NO')
				break
			if aa > bb and (not exists[-1]):
				print('NO')
				break
		else:
			print('YES')
ntvdm()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	state = True
	if a[0] != b[0]:
		print('NO')
	else:
		s.add(a[0])
		for i in range(1, n):
			if a[i] > b[i] and -1 not in s:
				print('NO')
				state = False
				break
			elif a[i] < b[i] and 1 not in s:
				print('NO')
				state = False
				break
			if a[i] not in s:
				s.add(a[i])
		if state == True:
			print('YES')


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


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()))
	s = set()
	for i in range(len(a)):
		if a[i] < b[i] and 1 not in s or (a[i] > b[i] and -1 not in s):
			print('NO')
			break
		s.add(a[i])
	else:
		print('YES')


for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	stack_of_1 = []
	stack_of_n1 = []
	for (index, x) in enumerate(a):
		if x == 1:
			stack_of_1.append(index)
		elif x == -1:
			stack_of_n1.append(index)
	pos = True
	for (j, aj, bj) in zip(range(N - 1, -1, -1), a[::-1], b[::-1]):
		if stack_of_1 != [] and stack_of_1[-1] >= j:
			stack_of_1.pop()
		if stack_of_n1 != [] and stack_of_n1[-1] >= j:
			stack_of_n1.pop()
		dif = bj - aj
		if dif > 0:
			if stack_of_1 == []:
				pos = False
				break
		if dif < 0:
			if stack_of_n1 == []:
				pos = False
				break
	print(['YES', 'NO'][pos == False])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	s = {a[0]}
	k = 0
	for i in range(1, n):
		if a[i] > b[i]:
			if -1 not in s:
				print('NO')
				k = 1
				break
		if a[i] < b[i]:
			if 1 not in s:
				print('NO')
				k = 1
				break
		s = s.union([a[i]])
	if k == 0:
		print('YES')


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	x = 10 ** 9 + 7
	z = 10 ** 9 + 7
	for i in range(len(A)):
		if A[i] == 1:
			x = i
			break
	for i in range(len(A)):
		if A[i] == -1:
			z = i
			break
	t = 0
	for i in range(len(B)):
		if A[i] == B[i]:
			t += 1
		else:
			val = B[i] - A[i]
			if val > 0 and x < i:
				t += 1
			elif val < 0 and z < i:
				t += 1
			else:
				break
	if t == N:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	b = map(int, input().split())
	(x, y) = (False, False)
	for (u, v) in zip(a, b):
		if u > v and (not x):
			print('NO')
			break
		if u < v and (not y):
			print('NO')
			break
		if u < 0:
			x = True
		if u > 0:
			y = True
		if x and y:
			print('YES')
			break
	else:
		print('YES')


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	res = 'YES'
	has_pos = False
	has_neg = False
	for (i, v) in enumerate(a):
		if v < b[i] and (not has_pos):
			res = 'NO'
			break
		if v > b[i] and (not has_neg):
			res = 'NO'
			break
		if v == 1:
			has_pos = True
		if v == -1:
			has_neg = True
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p_flag = 0
	n_flag = 0
	pr_flag = 0
	nr_flag = 0
	pn_flag = 0
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(1, n):
			if a[i - 1] > 0:
				p_flag = 1
			elif a[i - 1] < 0:
				n_flag = 1
			if a[i] > 0:
				pr_flag = 1
			elif a[i] < 0:
				nr_flag = 1
			if pr_flag == 1 and n_flag == 1 or (nr_flag == 1 and p_flag == 1):
				pn_flag = 1
			if a[i] != b[i]:
				if b[i] > 0:
					if p_flag == 1:
						continue
					else:
						print('NO')
						break
				elif b[i] == 0:
					if pn_flag == 1:
						continue
					else:
						print('NO')
						break
				elif n_flag == 1:
					continue
				else:
					print('NO')
					break
			else:
				continue
		else:
			print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	if 1 in a:
		j = a.index(1)
		in1 = j + 1
	else:
		j = n
		in1 = j
	if -1 in a:
		k = a.index(-1)
		in2 = k + 1
	else:
		k = n
		in2 = k
	f = 0
	if in1 > in2:
		ind = in1
	else:
		ind = in2
	for i1 in range(0, ind):
		if a[i1] == b[i1]:
			continue
		elif a[i1] > b[i1]:
			if i1 > k:
				continue
			else:
				print('NO')
				f = 1
				break
		elif i1 > j:
			continue
		else:
			print('NO')
			f = 1
			break
	if f == 0:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	x = [0] * 2
	flag = False
	for i in range(n):
		if a[i] > b[i] and x[0] == 0:
			print('NO')
			flag = True
			break
		elif a[i] < b[i] and x[1] == 0:
			print('NO')
			flag = True
			break
		elif a[i] == 1:
			x[1] = 1
		elif a[i] == -1:
			x[0] = -1
	if not flag:
		print('YES')
	t -= 1


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'YES'
	s = set()
	for i in range(n):
		if b[i] > a[i] and 1 not in s or (b[i] < a[i] and -1 not in s):
			ans = 'NO'
			break
		s.add(a[i])
	print(ans)


test = int(input())
for i in range(test):
	big = 0
	small = 0
	warning = 0
	sz = int(input())
	now = list(map(int, input().split()))
	want = list(map(int, input().split()))
	for j in range(sz):
		if now[j] < want[j] and big == 0 or (now[j] > want[j] and small == 0):
			warning += 1
			break
		elif now[j] == 1:
			big += 1
		elif now[j] == -1:
			small += 1
	if warning == 0:
		print('YES')
	else:
		print('NO')


import math

def run(a, b, l):
	p = n = 0
	if a[0] != b[0]:
		return 'NO'
	else:
		p = 1 if a[0] > 0 else 0
		n = 1 if a[0] < 0 else 0
		for i in range(1, l):
			if a[i] < b[i] and (not p) or (a[i] > b[i] and (not n)):
				return 'NO'
			p += 1 if a[i] > 0 else 0
			n += 1 if a[i] < 0 else 0
		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(run(a, b, n))


t = int(input())

def huntone(a, i):
	for item in range(i):
		if a[item] == 1:
			return True
	return False

def huntmone(a, i):
	for item in range(i):
		if a[item] == -1:
			return True
	return False
huntone([0, 2, 3, 4, 1], 5)

def is_possible(a, b, n):
	if n == 1:
		if a != b:
			return 'NO'
		else:
			return 'YES'
	if a[0] != b[0]:
		return 'NO'
	for i in range(1, n):
		if b[i] > a[i]:
			if huntone(a, i) == False:
				return 'NO'
		if b[i] < a[i]:
			if huntmone(a, i) == False:
				return 'NO'
	return 'YES'
answer = []
for item in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	answer.append(is_possible(a, b, n))
for item in answer:
	print(item)


from _collections import deque
import sys
sys.setrecursionlimit(10000)
import math
import heapq
import bisect
r = int(input())
t = -1

def input():
	global t
	t += 1
	return data[t]
data = sys.stdin.readlines()
inf = 2 * 10 ** 5
for i in range(r):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = {0}
	f = True
	fm = inf
	fo = inf
	for i in range(n):
		if a[i] == 1 and fo == inf:
			fo = i
		if a[i] == -1 and fm == inf:
			fm = i
	for i in range(n - 1, -1, -1):
		d = b[i] - a[i]
		if d == 0:
			continue
		elif d > 0 and i > fo:
			continue
		elif d < 0 and i > fm:
			continue
		else:
			f = False
	if f:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	ntest = int(stdin.readline())
	for test in range(ntest):
		n = int(stdin.readline())
		a = [int(x) for x in stdin.readline().split()]
		b = [int(x) for x in stdin.readline().split()]
		try:
			seta = set()
			assert a[0] == b[0]
			seta.add(a[0])
			for i in range(1, n):
				if a[i] < b[i]:
					assert 1 in seta
				if a[i] > b[i]:
					assert -1 in seta
				seta.add(a[i])
			stdout.write('YES\n')
		except:
			stdout.write('NO\n')
	return 0
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	grow = shrink = False
	for (ai, bi) in zip(a, b):
		if bi < ai:
			if not shrink:
				print('NO')
				break
		elif bi > ai and (not grow):
			print('NO')
			break
		if ai == 1:
			grow = True
		elif ai == -1:
			shrink = True
	else:
		print('YES')


import sys
t = int(input())
for _ in range(t):
	pr = False
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ind_plus = 0
	for i in a:
		if i == 1:
			break
		ind_plus += 1
	if ind_plus == n:
		ind_plus -= 1
	ind_minus = 0
	for i in a:
		if i == -1:
			break
		ind_minus += 1
	if ind_minus == n:
		ind_minus -= 1
	if ind_plus > ind_minus:
		if a[:ind_minus + 1] != b[:ind_minus + 1]:
			print('NO')
			continue
		for i in range(1, ind_plus - ind_minus + 1):
			if a[ind_minus + i] < b[ind_minus + i]:
				print('NO')
				pr = True
				break
		if not pr:
			print('YES')
	else:
		if a[:ind_plus + 1] != b[:ind_plus + 1]:
			print('NO')
			continue
		for i in range(1, ind_minus - ind_plus + 1):
			if a[ind_plus + i] > b[ind_plus + i]:
				print('NO')
				pr = True
				break
		if not pr:
			print('YES')


t = int(input())
while t > 0:
	ne = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		t -= 1
		continue
	(p, n, i, f) = (0, 0, 0, 0)
	while i < ne:
		if a[i] == 1:
			p += 1
		elif a[i] == -1:
			n += 1
		i += 1
	i = ne - 1
	while i > 0:
		if a[i] == 1:
			p -= 1
		elif a[i] == -1:
			n -= 1
		if a[i] < b[i]:
			if p <= 0:
				f = 1
				break
		elif a[i] > b[i]:
			if n <= 0:
				f = 1
				break
		i -= 1
	if f == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = set()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	for i in range(0, n):
		d = b[i] - a[i]
		if d != 0:
			if d > 0:
				if len(s) == 0 or 1 not in s:
					ans = 1
					break
			elif d < 0:
				if len(s) == 0 or -1 not in s:
					ans = 1
					break
		if a[i] not in s:
			s.add(a[i])
	if ans == 1:
		print('NO')
	else:
		print('YES')


def solve():
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	seen_positive = False
	seen_negative = False
	for i in range(N):
		if B[i] > A[i] and (not seen_positive):
			return 'NO'
		if B[i] < A[i] and (not seen_negative):
			return 'NO'
		if A[i] > 0:
			seen_positive = True
		if A[i] < 0:
			seen_negative = True
	return 'YES'
T = int(input())
for t in range(T):
	print(solve())


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	(x, y) = (0, 0)
	ans = True
	for i in range(len(a)):
		if a[i] > b[i] and y == 0:
			ans = False
			break
		if a[i] < b[i] and x == 0:
			ans = False
			break
		if a[i] == 1:
			x = 1
		if a[i] == -1:
			y = 1
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	check1 = 0
	check2 = 0
	flag = 0
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] < b[i] and check1 > 0:
			pass
		elif a[i] > b[i] and check2 > 0:
			pass
		else:
			flag = 1
			break
		if a[i] == 1:
			check1 = 1
		elif a[i] == -1:
			check2 = 1
		else:
			pass
	if flag == 0:
		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()]
	if a[0] != b[0]:
		print('NO')
	else:
		ma = min(a)
		mb = min(b)
		Ma = max(a)
		Mb = max(b)
		if ma > 0 and mb < 0:
			print('NO')
		elif Ma < 0 and Mb > 0:
			print('NO')
		else:
			s = 0
			v = 0
			for i in range(1, n):
				for j in range(i):
					if a[j] != 0:
						a1 = 0
						b1 = 0
						if abs(b[i] - a[i]) == b[i] - a[i]:
							a1 += 1
						if abs(a[j]) == a[j]:
							b1 += 1
						if (b[i] - a[i]) % a[j] == 0 and a1 == b1:
							s = 1
							break
				if s != 1 and a[i] != b[i]:
					v = 1
					print('NO')
					break
				s = 0
			if v == 0:
				print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	A = tuple(map(int, input().split()))
	B = tuple(map(int, input().split()))
	flag = set()
	ans = 'YES'
	if A[0] != B[0]:
		print('NO')
		continue
	for (a, b) in zip(A, B):
		if a == b:
			if a > 0 and 1 not in flag:
				flag.add(1)
			elif a < 0 and -1 not in flag:
				flag.add(-1)
		elif a < b:
			if 1 in flag:
				if a < 0 and -1 not in flag:
					flag.add(-1)
			else:
				ans = 'NO'
				break
		elif -1 in flag:
			if a > 0 and 1 not in flag:
				flag.add(1)
		else:
			ans = 'NO'
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	ipos = n
	ineg = n
	for i in range(n):
		if a[i] == 1 and ipos == n:
			ipos = i
			if ineg < n:
				break
		if a[i] == -1 and ineg == n:
			ineg = i
			if ipos < n:
				break
	for i in range(n):
		if a[i] < b[i] and i <= ipos:
			print('NO')
			break
		if a[i] > b[i] and i <= ineg:
			print('NO')
			break
	else:
		print('YES')


import math

def helper(a, b, n):
	d1 = False
	dm1 = False
	if a[0] != b[0]:
		return 'NO'
	else:
		if a[0] > 0:
			d1 = True
		if a[0] < 0:
			dm1 = True
	for n in range(1, N):
		if a[n] != b[n]:
			if b[n] < 0 and (not dm1):
				return 'NO'
			if b[n] > 0 and (not d1):
				return 'NO'
			if b[n] == 0 and a[n] == 1 and (not dm1):
				return 'NO'
			if b[n] == 0 and a[n] == -1 and (not d1):
				return 'NO'
		if a[n] > 0:
			d1 = True
		if a[n] < 0:
			dm1 = True
	return 'YES'
T = int(input())
for t in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(helper(a, b, N))


t = int(input())
for q in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flagPLus = False
	flagMinus = False
	flag = True
	for i in range(0, n):
		if a[i] == b[i] and a[i] > 0:
			flagPLus = True
		if a[i] == b[i] and a[i] < 0:
			flagMinus = True
		if a[i] != b[i]:
			if (b[i] > 0 or (b[i] == 0 and a[i] == -1)) and (not flagPLus):
				print('NO')
				flag = False
				break
			if (b[i] < 0 or (b[i] == 0 and a[i] == 1)) and (not flagMinus):
				print('NO')
				flag = False
				break
			if a[i] < 0:
				flagMinus = True
			if a[i] > 0:
				flagPLus = True
	if flag:
		print('YES')


i = input
v = lambda : map(int, i().split())
(Y, N) = ('YES', 'NO')

def f():
	s = 0
	for (a, b) in zip(v(), v()):
		if not s:
			if a != b:
				return N
			s = a
		elif a != b and (a > b) == (s > 0):
			return N
		elif a != 0 and (a > 0) != (s > 0):
			return Y
	return Y
for q in range(int(i())):
	(i(), print(f()))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(f1, f2) = (0, 0)
	(i, j) = (n, n)
	for x in range(n):
		if f1 and f2:
			break
		elif not f1 and a[x] == 1:
			i = x
			f1 = 1
		elif not f2 and a[x] == -1:
			j = x
			f2 = 1
	t = n if i == n or j == n else max(i, j) + 1
	for y in range(t):
		if a[y] < b[y] and i >= y:
			print('NO')
			break
		elif a[y] > b[y] and j >= y:
			print('NO')
			break
	else:
		print('YES')


for i in range(int(input())):
	t = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if b[0] == a[0]:
		if 1 in a:
			one = a.index(1)
		else:
			one = 'u'
		if -1 in a:
			mione = a.index(-1)
		else:
			mione = 'y'
		g = 0
		for k in range(1, t):
			if b[k] > a[k]:
				if one != 'u':
					if k > one:
						pass
					else:
						print('NO')
						g += 1
						break
				else:
					print('NO')
					g += 1
					break
			elif b[k] < a[k]:
				if mione != 'y':
					if k > mione:
						pass
					else:
						print('NO')
						g += 1
						break
				else:
					print('NO')
					g += 1
					break
			else:
				pass
		if g == 0:
			print('YES')
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline()[:-1]
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(plus, minus) = (n, n)
	for (i, x) in enumerate(a):
		if x == -1:
			minus = min(minus, i)
		elif x == 1:
			plus = min(plus, i)
	ok = True
	for i in range(n):
		if a[i] < b[i] and plus >= i:
			ok = False
		if a[i] > b[i] and minus >= i:
			ok = False
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for numtests in range(t):
	n = int(input())
	a = input().split()
	b = input().split()
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	possible = True
	zero = True
	index = 0
	while zero and index < n:
		if a[index] == 0:
			if b[index] == 0:
				index += 1
			else:
				possible = False
				zero = False
		else:
			zero = False
	notfound = True
	godtier = 0
	if index < n:
		if a[index] == b[index]:
			godtier = a[index]
			index += 1
		else:
			possible = False
	while possible and notfound and (index < n):
		if a[index] + godtier == 0:
			if (b[index] - a[index]) * godtier > -1:
				notfound = False
			else:
				possible = False
		elif (b[index] - a[index]) * godtier < 0:
			possible = False
		else:
			index += 1
	if possible:
		print('YES')
	else:
		print('NO')


def check(a, b, n):
	set3 = list()
	if a[0] != b[0]:
		return False
	set3.append(a[0])
	for i in range(1, n):
		if a[i] != b[i]:
			if a[i] > b[i]:
				if -1 not in set3:
					return False
			elif 1 not in set3:
				return False
		if a[i] not in set3:
			set3.append(a[i])
		if -1 in set3 and 1 in set3:
			return True
	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, n):
		print('YES')
	else:
		print('NO')


from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

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

def si():
	return str(input())

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

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1
for _ in range(ii()):
	n = ii()
	l = li()
	m = li()
	(a, b) = (0, 0)
	ans = 'YES'
	for i in range(n):
		if l[i] == m[i] and l[i] == 1:
			a = 1
		elif l[i] == m[i] and l[i] == -1:
			b = 1
		elif l[i] == m[i] and l[i] == 0:
			pass
		elif l[i] > m[i]:
			if b != 1:
				ans = 'NO'
				break
		elif l[i] < m[i]:
			if a != 1:
				ans = 'NO'
				break
		if l[i] == -1:
			b = 1
		elif l[i] == 1:
			a = 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 10000000.0
	l = 10000000.0
	try:
		k = a.index(1)
	except:
		pass
	try:
		l = a.index(-1)
	except:
		pass
	out = 'YES'
	for i in range(n - 1, -1, -1):
		if b[i] > a[i] and i <= k or (b[i] < a[i] and i <= l):
			out = 'NO'
			break
	print(out)


t = int(input())
for _ in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [-1] * N
	d = [1] * N
	for i in range(1, N):
		c[i] = max(c[i - 1], a[i - 1])
		d[i] = min(d[i - 1], a[i - 1])
	flag = True
	for i in range(N - 1, -1, -1):
		diff = b[i] - a[i]
		if diff > 0 and c[i] <= 0:
			flag = False
			break
		elif diff < 0 and d[i] >= 0:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


for k in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'YES'
	s = set()
	for i in range(n):
		if b[i] > a[i] and 1 not in s or (b[i] < a[i] and -1 not in s):
			ans = 'NO'
			break
		s.add(a[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = 0
	b = 0
	c = 0
	hell = 0
	if l1[0] != l2[0]:
		print('NO')
	else:
		for i in range(n - 1, -1, -1):
			if l1[i] == 0:
				a = i
			if l1[i] == 1:
				b = i
			if l1[i] == -1:
				c = i
		for i in range(n - 1, 0, -1):
			if l1[i] == l2[i]:
				continue
			else:
				if l1[i] > l2[i]:
					if l1[c] != -1:
						hell = 1
						break
					if c >= i:
						hell = 1
						break
				if l1[i] < l2[i]:
					if l1[b] != 1:
						hell = 1
						break
					if b >= i:
						hell = 1
						break
		if hell == 1:
			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(' ')))
	x = set()
	ans = 'YES'
	for i in range(n):
		if a[i] != b[i] and i == 0:
			ans = 'NO'
			break
		elif a[i] == b[i]:
			x.add(a[i])
		elif a[i] > b[i]:
			if -1 not in x:
				ans = 'NO'
				break
			else:
				x.add(a[i])
		elif 1 not in x:
			ans = 'NO'
		else:
			x.add(a[i])
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
	else:
		p = 0
		cm = 0
		cp = 0
		for i in range(1, n):
			if a[i] != b[i]:
				if a[i] > b[i]:
					if cm == 1:
						pass
					elif a[:i].count(-1) <= 0:
						print('NO')
						p = 1
						break
					else:
						cm = 1
				elif b[i] > a[i]:
					if cp == 1:
						pass
					elif a[:i].count(1) <= 0:
						print('NO')
						p = 1
						break
					else:
						cp = 1
		if p == 0:
			print('YES')


t = int(input())
for wer in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	t = True
	for i in range(n):
		if a[i] > b[i] and -1 in s:
			s.add(a[i])
		elif a[i] < b[i] and 1 in s:
			s.add(a[i])
		elif a[i] == b[i]:
			s.add(a[i])
		else:
			t = False
			break
	if t:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def write(_s):
	stdout.write(_s)

def writeint(_s):
	stdout.write(str(_s))

def writelist(_l):
	stdout.write(''.join(_l))

def read():
	return stdin.readline().split(' ')

def readint():
	return int(stdin.readline())

def readints():
	return map(int, stdin.readline().split(' '))
t = readint()
while t:
	n = readint()
	a = list(readints())
	b = list(readints())
	if a[0] != b[0]:
		write('NO')
	else:
		ok = True
		positive = a[0] > 0
		negative = a[0] < 0
		for i in range(1, n):
			if b[i] > a[i] and (not positive):
				write('NO')
				ok = False
				break
			elif b[i] < a[i] and (not negative):
				write('NO')
				ok = False
				break
			if a[i] > 0:
				positive = True
			if a[i] < 0:
				negative = True
		if ok:
			write('YES')
	write('\n')
	t -= 1


def solve_test_case(t):
	n = int(input())
	a = parse_array(int)
	b = parse_array(int)
	if a[0] != b[0]:
		print('NO')
		return
	previous_numbers = {a[0]}
	for j in range(1, n):
		diff = b[j] - a[j]
		for elt in previous_numbers:
			if elt != 0 and (not (elt > 0) ^ (diff > 0)):
				diff = diff % elt
				if diff == 0:
					break
		if diff != 0:
			print('NO')
			return
		previous_numbers.add(a[j])
	print('YES')

def parse_array(f):
	return list(map(f, input().split()))

def solve():
	T = int(input())
	for t in range(T):
		solve_test_case(t)
solve()


import os
import math
import operator
import sys
from collections import defaultdict, deque
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [int(k) for k in input().split()]
		b = [int(k) for k in input().split()]
		dic = {}
		counter = 0
		for i in range(n):
			if a[i] == b[i]:
				dic[a[i]] = 1
				continue
			if b[i] > a[i]:
				if 1 in dic:
					dic[a[i]] = 1
					continue
				else:
					counter = 1
					break
			elif -1 in dic:
				dic[a[i]] = 1
				continue
			else:
				counter = 1
				break
		if counter == 1:
			print('NO')
		else:
			print('YES')
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()


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


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	first0 = n + 1
	first1 = n + 1
	first2 = n + 1
	poss = False
	for i in range(n):
		if a[i] == 0:
			first0 = i
			break
	for i in range(n):
		if a[i] == 1:
			first1 = i
			break
	for i in range(n):
		if a[i] == -1:
			first2 = i
			break
	j = n - 1
	while j >= 0:
		if b[j] > a[j] and j > first1:
			poss = True
		elif b[j] < a[j] and j > first2:
			poss = True
		elif b[j] == a[j]:
			poss = True
		else:
			poss = False
			break
		j -= 1
	if poss:
		print('YES')
	else:
		print('NO')


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

def ss():
	return input()

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

def li():
	return map(int, input().split())
t = ii()
for _ in range(t):
	n = ii()
	a = ll()
	b = ll()
	f1 = 0
	f2 = 0
	f = 0
	for i in range(n):
		if a[i] > b[i] and f2 == 0:
			f = 1
		if a[i] < b[i] and f1 == 0:
			f = 1
		if a[i] == 1:
			f1 = 1
		if a[i] == -1:
			f2 = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


def main_function():
	a_s = []
	b_s = []
	for i in range(int(input())):
		n = int(input())
		a_s.append([int(i) for i in input().split(' ')])
		b_s.append([int(i) for i in input().split(' ')])
	for i in range(len(a_s)):
		a = a_s[i]
		b = b_s[i]
		is_answer_given = False
		hash = [0, 0, 0]
		for k in range(len(a)):
			if b[k] > a[k]:
				if hash[2] == 0:
					print('NO')
					is_answer_given = True
					break
			elif b[k] < a[k]:
				if hash[0] == 0:
					print('NO')
					is_answer_given = True
					break
			if a[k] == 1:
				hash[2] = 1
			elif a[k] == -1:
				hash[0] = 1
		if not is_answer_given:
			print('YES')
main_function()


def solve(a, b):
	min_add_idx = 10 ** 5
	min_sub_idx = 10 ** 5
	for (i, aa) in enumerate(a):
		if b[i] - a[i] > 0:
			if i < min_add_idx:
				print('NO')
				return
		if b[i] - a[i] < 0:
			if i < min_sub_idx:
				print('NO')
				return
		if aa == 1:
			min_add_idx = min(min_add_idx, i)
		if aa == -1:
			min_sub_idx = min(min_sub_idx, i)
	print('YES')
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(a, b)


import sys, bisect
from math import gcd
input = sys.stdin.readline

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

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

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

def invr():
	return map(int, input().rstrip().split())
t = inp()
for _ in range(t):
	n = inp()
	ass = inlt()
	bss = inlt()
	pos = False
	neg = False
	if ass[0] != bss[0]:
		print('NO')
	else:
		has = True
		if ass[0] > 0:
			pos = True
		elif bss[0] < 0:
			neg = True
		for i in range(1, n):
			if ass[i] != bss[i]:
				if bss[i] > ass[i]:
					if not pos:
						has = False
						break
				elif not neg:
					has = False
					break
			if ass[i] > 0:
				pos = True
			elif ass[i] < 0:
				neg = True
		if has:
			print('YES')
		else:
			print('NO')


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	minus_one_present = 0
	one_present = 0
	flag = 0
	for i in range(len(a)):
		if a[i] < b[i]:
			if one_present == 1:
				if a[i] == 1:
					one_present = 1
				elif a[i] == -1:
					minus_one_present = 1
				continue
			else:
				flag = 1
				break
		elif a[i] > b[i]:
			if minus_one_present == 1:
				if a[i] == 1:
					one_present = 1
				elif a[i] == -1:
					minus_one_present = 1
				continue
			else:
				flag = 1
				break
		elif a[i] == 1:
			one_present = 1
		elif a[i] == -1:
			minus_one_present = 1
	if flag == 0:
		print('YES')
	elif flag == 1:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ones = 0
	nones = 0
	flag = 1
	for i in range(n):
		if a[i] > b[i] and nones == 0:
			print('NO')
			flag = 0
			break
		elif a[i] < b[i] and ones == 0:
			print('NO')
			flag = 0
			break
		if a[i] == 1:
			ones += 1
		elif a[i] == -1:
			nones += 1
	if flag:
		print('YES')


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	a = iia()
	b = iia()
	mone = one = 0
	for (i, j) in zip(a, b):
		if j > i and (not one):
			print('NO')
			break
		elif i > j and (not mone):
			print('NO')
			break
		if i == -1:
			mone = 1
		if i == 1:
			one = 1
	else:
		print('YES')


import copy
import sys
input = lambda : sys.stdin.readline().rstrip()

def solve(A, B):
	(hp, hn) = (0, 0)
	for i in range(len(A)):
		if B[i] < A[i] and (not hn):
			print('NO')
			return
		if B[i] > A[i] and (not hp):
			print('NO')
			return
		if A[i] < 0:
			hn = 1
		if A[i] > 0:
			hp = 1
	print('YES')
tests = int(input())
for test in range(1, tests + 1):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	solve(A, B)


from collections import defaultdict
from math import gcd
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	count = []
	cnt0 = 0
	cnt1 = 0
	cnt1n = 0
	for i in range(n):
		if arr[i] == 0:
			cnt0 += 1
		if arr[i] == 1:
			cnt1 += 1
		if arr[i] == -1:
			cnt1n += 1
		count.append([cnt0, cnt1, cnt1n])
	flag = True
	for i in range(n - 1, -1, -1):
		if arr[i] == brr[i]:
			continue
		if arr[i] > brr[i] and i != 0:
			if count[i - 1][2] == 0:
				flag = False
				break
		elif arr[i] < brr[i] and i != 0:
			if count[i - 1][1] == 0:
				flag = False
				break
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	one = 999999999
	minusone = 999999999
	flag2 = 0
	flag1 = 0
	res = 'YES'
	ze = 0
	on = 0
	mi = 0
	for i in range(0, n):
		if flag1 == 0 and a[i] == 1:
			one = i
			flag1 = 1
		if flag2 == 0 and a[i] == -1:
			minusone = i
			flag2 = 1
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		elif a[i] < b[i]:
			if one < i:
				continue
			else:
				res = 'NO'
				break
		elif minusone < i:
			continue
		else:
			res = 'NO'
			break
	print(res)


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()]
	i = 0
	fp = -1
	fn = -1
	while i < n:
		if fp > -1 and fn > -1:
			break
		if fp == -1 and a[i] == 1:
			fp = i
		if fn == -1 and a[i] == -1:
			fn = i
		i += 1
	if fp == -1:
		fp = n - 1
	if fn == -1:
		fn = n - 1
	i = 0
	can = True
	while i < max(fp, fn) + 1:
		if i <= fn and a[i] > b[i]:
			can = False
			break
		if i <= fp and a[i] < b[i]:
			can = False
			break
		i += 1
	if can:
		print('YES')
	else:
		print('NO')


T = int(input())
res = []
for t in range(T):
	n = int(input())
	one = 0
	minus = 0
	count = 0
	a = [int(k) for k in input().split()]
	b = [int(k) for k in input().split()]
	for i in range(n):
		if a[i] == b[i]:
			if a[i] == 1:
				one += 1
			elif a[i] == -1:
				minus += 1
			count += 1
		elif a[i] < b[i] and one != 0:
			if a[i] == 1:
				one += 1
			elif a[i] == -1:
				minus += 1
			count += 1
		elif a[i] > b[i] and minus != 0:
			if a[i] == 1:
				one += 1
			elif a[i] == -1:
				minus += 1
			count += 1
		else:
			res.append('NO')
			break
	if count == n:
		res.append('YES')
for i in res:
	print(i)


def solve(a, b):
	isPosPresent = False
	isNegPresent = False
	for i in range(0, len(a)):
		if a[i] > b[i] and isNegPresent == False or (a[i] < b[i] and isPosPresent == False):
			print('NO')
			return
		elif a[i] > 0:
			isPosPresent = True
		elif a[i] < 0:
			isNegPresent = True
	print('YES')
t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(lambda x: int(x), input().split()))
	b = list(map(lambda x: int(x), input().split()))
	solve(a, b)


n = input
v = lambda : map(int, n().split())

def f():
	s = 0
	for (a, b) in zip(v(), v()):
		if s == 0:
			if a != b:
				return 'NO'
			s = a
		elif s > 0:
			if a > b:
				return 'NO'
			if a < 0:
				return 'YES'
		elif s < 0:
			if a < b:
				return 'NO'
			if a > 0:
				return 'YES'
	return 'YES'
for i in range(int(n())):
	(n(), print(f()))


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


def jisuan(list2):
	if 1 not in set1 and -1 not in set1:
		for x in list2:
			if x != 0:
				return 'NO'
	elif 1 not in set1:
		a = list1.index(-1)
		for x in list2[:a]:
			if x != 0:
				return 'NO'
		if list2[a] != -1:
			return 'NO'
		for i in range(a, n):
			if list2[i] > list1[i]:
				return 'NO'
	elif -1 not in set1:
		a = list1.index(1)
		for x in list2[:a]:
			if x != 0:
				return 'NO'
		if list2[a] != 1:
			return 'NO'
		for i in range(a, n):
			if list2[i] < list1[i]:
				return 'NO'
	else:
		a = list1.index(1)
		b = list1.index(-1)
		for x in list2[:min(a, b)]:
			if x != 0:
				return 'NO'
		if a > b:
			if list2[b] != -1:
				return 'NO'
			for i in range(b, a + 1):
				if list1[i] < list2[i]:
					return 'NO'
		else:
			if list2[a] != 1:
				return 'NO'
			for i in range(a, b + 1):
				if list1[i] > list2[i]:
					return 'NO'
	return 'YES'
list_ans = []
for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	set1 = set(list1)
	list_ans.append(jisuan(list2))
for item in list_ans:
	print(item)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {-1: 0, 0: 0, 1: 0}
	flag = 0
	for j in range(n):
		if b[j] - a[j] < 0:
			if d[-1] == 0:
				flag = 1
				print('NO')
				break
		elif b[j] > a[j]:
			if d[1] == 0:
				flag = 1
				print('NO')
				break
		d[a[j]] = 1
		if d == {-1: 1, 0: 1, 1: 1}:
			flag = 1
			print('YES')
			break
	if flag == 0:
		print('YES')


test = int(input())
for _ in range(test):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	up = False
	down = False
	ok = True
	for i in range(n):
		if ok:
			if b[i] != a[i]:
				if b[i] > a[i] and (not up):
					ok = False
				if b[i] < a[i] and (not down):
					ok = False
			if a[i] == -1:
				down = True
			if a[i] == 1:
				up = True
		else:
			break
	print('YES' if ok else 'NO')


t = int(input())
while t:
	n = int(input())
	a = input().split()
	a = [int(x) for x in a]
	b = input().split()
	b = [int(x) for x in b]
	(x, y, z) = (0, 0, 0)
	for i in range(n):
		x += a[i] == -1
		z += a[i] == 1
	flag = True
	for i in range(n - 1, -1, -1):
		x -= a[i] == -1
		z -= a[i] == 1
		if b[i] - a[i] > 0 and z == 0:
			flag = False
		elif b[i] - a[i] < 0 and x == 0:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag1 = flag2 = False
	pos_i = neg_i = -1
	for j in range(n):
		if flag1 and flag2:
			break
		if a[j] == 1 and (not flag1):
			pos_i = j
			flag1 = True
		elif a[j] == -1 and (not flag2):
			neg_i = j
			flag2 = True
	for j in range(n):
		if a[j] == b[j]:
			continue
		if a[j] > b[j]:
			if neg_i == -1 or neg_i >= j:
				print('NO')
				break
		elif a[j] < b[j]:
			if pos_i == -1 or pos_i >= j:
				print('NO')
				break
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	hash_map = {}
	flag = True
	for i in range(n):
		if a[i] > b[i]:
			if -1 not in hash_map:
				flag = False
				break
			if a[i] not in hash_map:
				hash_map[a[i]] = 1
		elif a[i] < b[i]:
			if 1 not in hash_map:
				flag = False
				break
			if a[i] not in hash_map:
				hash_map[a[i]] = 1
		elif a[i] == b[i]:
			if a[i] not in hash_map:
				hash_map[a[i]] = 1
	if flag:
		print('YES')
	else:
		print('NO')


import sys
import heapq

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

def iinput():
	return int(input())

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

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

def YES(flag):
	if flag:
		return 'YES'
	return 'NO'

def main():

	def pro(flag):
		if flag:
			return True
		return False
	n = iinput()
	(q, w) = (rlinput(), rlinput())
	(fl, res, fl1) = (False, True, False)
	for i in range(n):
		if res:
			if q[i] > w[i]:
				res = pro(fl1)
			elif q[i] < w[i]:
				res = pro(fl)
			if q[i] == 1:
				fl = True
			elif q[i] == -1:
				fl1 = True
	print(YES(res))
for i in range(iinput()):
	main()


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	Query.append((N, A, B))
for (N, A, B) in Query:
	ism = N
	isp = N
	for (i, a) in enumerate(A):
		if a < 0 and ism == N:
			ism = i
		if a > 0 and isp == N:
			isp = i
	ok = True
	for (i, (a, b)) in enumerate(zip(A, B)):
		if a > b and ism >= i:
			ok = False
		if a < b and isp >= i:
			ok = False
	print('YES' if ok else 'NO')


t = int(input())
for _ in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	n = False
	z = False
	p = False
	ret = True
	if a[0] == 0 and b[0] != 0:
		print('NO')
		continue
	for i in range(N):
		if a[i] > b[i] and n:
			if a[i] == -1:
				n = True
			elif a[i] == 0:
				z = True
			elif a[i] == 1:
				p = True
			continue
		elif a[i] < b[i] and p:
			if a[i] == -1:
				n = True
			elif a[i] == 0:
				z = True
			elif a[i] == 1:
				p = True
			continue
		elif a[i] == b[i]:
			if a[i] == -1:
				n = True
			elif a[i] == 0:
				z = True
			elif a[i] == 1:
				p = True
			continue
		ret = False
		break
	if ret:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	cnt1 = 0
	cnt0 = 0
	cnt2 = 0
	tr = 0
	for i in range(n):
		if i > 0:
			if l[i - 1] == 1:
				cnt1 = 1
			elif l[i - 1] == -1:
				cnt2 = 1
			else:
				cnt0 = 1
		if l1[i] > l[i]:
			if cnt1 == 1:
				continue
			else:
				tr = 1
				break
		elif l1[i] < l[i]:
			if cnt2 == 1:
				continue
			else:
				tr = 1
				break
	if tr == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	i = 0
	ne = 0
	po = 0
	f = 0
	if l1[i] != l2[i]:
		f = 1
	else:
		if l1[i] > 0:
			po += 1
		if l1[i] < 0:
			ne += 1
		while i < n:
			if l1[i] > l2[i]:
				if ne == 0:
					f = 1
					break
			if l1[i] < l2[i]:
				if po == 0:
					f = 1
					break
			if l1[i] > 0:
				po += 1
			if l1[i] < 0:
				ne += 1
			if po > 0 and ne > 0:
				f = 0
				break
			i += 1
	if f == 1:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = 0
	d = set()
	for i in range(n):
		if a[i] != b[i]:
			z = b[i] - a[i]
			if z > 0:
				f = 0
				for j in range(1, int(z ** 0.33) + 1, 1):
					if z % j == 0:
						if j in d:
							f = 1
							break
			else:
				f = 0
				for j in range(1, int(abs(z) ** 0.33) + 1, 1):
					if z % j == 0:
						if -1 * j in d:
							f = 1
							break
			if f == 0:
				c = 1
				break
		d.add(a[i])
	if c == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for x in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	b = [int(item) for item in input().split()]
	on = [False] * n
	mn = [False] * n
	ok = True if a[0] == b[0] else False
	if ok:
		for i in range(1, n):
			on[i] = on[i - 1] or a[i - 1] == 1
			mn[i] = mn[i - 1] or a[i - 1] == -1
			if b[i] > a[i] and on[i] == False or (b[i] < a[i] and mn[i] == False):
				ok = False
				break
	print('YES' if ok else 'NO')


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


for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a == b:
		print('YES')
		continue
	z = -1
	o = -1
	m = -1
	for i in range(n):
		if a[i] == 0 and z == -1:
			z = i
		elif a[i] == 1 and o == -1:
			o = i
		elif a[i] == -1 and m == -1:
			m = i
	ans = 'YES'
	for i in range(n - 1, -1, -1):
		x = b[i] - a[i]
		if x == 0:
			continue
		if x < 0:
			if m == -1 or m >= i:
				ans = 'NO'
				break
		if x > 0:
			if o == -1 or o >= i:
				ans = 'NO'
				break
	print(ans)


case = int(input())
answers = []
while case:
	case -= 1
	L = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	possible = None
	if L < 2:
		if a[0] == b[0]:
			possible = 'YES'
		else:
			possible = 'NO'
	elif a[0] != b[0]:
		possible = 'NO'
	else:
		possible = 'YES'
		one_before = a[0] == 1
		minus_before = a[0] == -1
		for i in range(1, L):
			aa = a[i]
			bb = b[i]
			q1 = aa < bb and one_before
			q2 = aa > bb and minus_before
			one_before |= a[i] == 1
			minus_before |= a[i] == -1
			if aa == bb or q1 or q2:
				continue
			else:
				possible = 'NO'
				break
	if possible is not None:
		answers.append(possible)
	else:
		print('ERROR')
		exit()
for ans in answers:
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	s = set()
	flag = True
	for i in range(n):
		d = B[i] - A[i]
		if d > 0:
			if 1 not in s:
				flag = False
		elif d < 0:
			if -1 not in s:
				flag = False
		else:
			pass
		s.add(A[i])
	if flag:
		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()))
	flag = True
	pos = False
	neg = False
	pos_index = a.index(1) if a.count(1) > 0 else 100000000000000000000
	neg_index = a.index(-1) if a.count(-1) > 0 else 10000000000000000000
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(1, n):
			if pos and neg:
				flag = True
				break
			if a[i] > 0:
				pos = True
			elif a[i] < 0:
				neg = True
			if True:
				if b[i] > a[i] and pos_index >= i:
					print('NO')
					flag = False
					break
				elif b[i] < a[i] and neg_index >= i:
					print('NO')
					flag = False
					break
				else:
					continue
		if flag:
			print('YES')


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	uniqueValues = set()
	for index in range(n):
		if a[index] < b[index] and 1 not in uniqueValues or (a[index] > b[index] and -1 not in uniqueValues):
			print('NO')
			break
		else:
			uniqueValues.add(a[index])
		if index == n - 1:
			print('YES')


def solve(a, b):
	n = len(a)
	s = set()
	res = True
	for i in range(1, n):
		s.add(a[i - 1])
		offset = b[i] - a[i]
		res &= (offset == 0) | (offset > 0 and 1 in s) | (offset < 0 and -1 in s)
	if res and a[0] == b[0]:
		return 'YES'
	return 'NO'
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()]
	print(solve(a, b))


def help(a, b, s):
	if a[0] != b[0]:
		return 'NO'
	for i in range(1, s):
		if b[i] > a[i]:
			for j in range(i):
				if a[j] == 1:
					break
			else:
				return 'NO'
		elif b[i] < a[i]:
			for j in range(i):
				if a[j] == -1:
					break
			else:
				return 'NO'
		elif b[i] == a[i]:
			continue
	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(help(a, b, n))


from sys import stdin, stdout
for i in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	ans = 'YES'
	s = set()
	for i in range(n):
		if b[i] > a[i] and 1 not in s:
			ans = 'NO'
			break
		elif b[i] < a[i] and -1 not in s:
			ans = 'NO'
			break
		s.add(a[i])
	print(ans)


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


from sys import stdin
inp = stdin.readline
t = int(inp())
while t:
	t -= 1
	n = int(inp())
	a = list(map(int, inp().split()))
	b = list(map(int, inp().split()))
	one_present = False
	minus_one_present = False
	if a[0] != b[0]:
		print('NO')
	else:
		ans = True
		for i in range(n):
			if b[i] > a[i] and (not one_present):
				ans = False
				break
			elif b[i] < a[i] and (not minus_one_present):
				ans = False
				break
			if a[i] == 1:
				one_present = True
			elif a[i] == -1:
				minus_one_present = True
		print('YES' if ans else 'NO')


def solvable(a, b):
	seen_neg = False
	seen_pos = False
	for (ai, bi) in zip(a, b):
		if ai < bi:
			if seen_pos:
				pass
			else:
				return False
		elif ai > bi:
			if seen_neg:
				pass
			else:
				return False
		if ai < 0:
			seen_neg = True
		if ai > 0:
			seen_pos = True
		if seen_neg and seen_pos:
			return True
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(j) for j in input().split()]
	if solvable(a, b):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	length = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	negative = False
	positive = False
	worked = True
	for c in range(length):
		if a[c] > b[c] and negative == False:
			print('NO')
			worked = False
			break
		elif a[c] < b[c] and positive == False:
			print('NO')
			worked = False
			break
		if a[c] == -1:
			negative = True
		if a[c] == 1:
			positive = True
	if worked:
		print('YES')


from collections import defaultdict
from math import log2, floor
from pprint import pprint
mod = pow(10, 9) + 7
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dict = defaultdict(int)
	for i in a:
		dict[i] += 1
	flag = 1
	for i in range(n - 1, -1, -1):
		dict[a[i]] -= 1
		if a[i] == b[i]:
			continue
		elif a[i] < b[i]:
			if dict[1] >= 1:
				continue
			else:
				flag = 0
				break
		elif a[i] > b[i]:
			if dict[-1] >= 1:
				continue
			else:
				flag = 0
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


def main():
	for case in range(int(input())):
		n = int(input())
		series_a = [int(x) for x in input().split()]
		series_b = [int(x) for x in input().split()]
		tool_box = set([0])
		no_flag = False
		for i in range(n):
			if series_a[i] == series_b[i]:
				if 0 in tool_box:
					tool_box.add(series_a[i])
				else:
					no_flag = True
					break
			elif series_a[i] < series_b[i]:
				if 1 in tool_box:
					tool_box.add(series_a[i])
				else:
					no_flag = True
					break
			elif -1 in tool_box:
				tool_box.add(series_a[i])
			else:
				no_flag = True
				break
		if no_flag:
			print('NO')
		else:
			print('YES')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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()


T = int(input())
for _ in range(0, T):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	temp = 'YES'
	c1 = 0
	c2 = 0
	c3 = 0
	for i in range(0, len(a)):
		if a[i] > b[i] and c1 == 0:
			temp = 'NO'
			break
		if a[i] < b[i] and c3 == 0:
			temp = 'NO'
			break
		if a[i] > 0:
			c3 = 1
		if a[i] < 0:
			c1 = 1
		if a[i] == 0:
			c2 = 1
	print(temp)


import calendar
t = int(input())
for _ in range(t):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	positive = 0
	negative = 0
	zero = 0
	for i in range(n):
		if arr1[i] < arr2[i]:
			if positive == 1:
				pass
			else:
				print('NO')
				break
		elif arr1[i] > arr2[i]:
			if negative == 1:
				pass
			else:
				print('NO')
				break
		if arr1[i] == 0:
			zero = 1
		elif arr1[i] == 1:
			positive = 1
		elif arr1[i] == -1:
			negative = 1
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	if a[0] != b[0]:
		print('NO')
		continue
	components = [0 for j in range(n)]
	for j in range(1, n):
		if a[j - 1] == 1:
			if components[j - 1] == 0:
				components[j] = 1
			elif components[j - 1] == -1:
				components[j] = 2
			elif components[j - 1] == 1:
				components[j] = 1
			elif components[j - 1] == 2:
				components[j] = 2
		elif a[j - 1] == -1:
			if components[j - 1] == 0:
				components[j] = -1
			elif components[j - 1] == -1:
				components[j] = -1
			elif components[j - 1] == 1:
				components[j] = 2
			elif components[j - 1] == 2:
				components[j] = 2
		else:
			components[j] = components[j - 1]
	done = False
	for j in reversed(range(n)):
		if a[j] == b[j]:
			continue
		if components[j] == 2:
			continue
		if a[j] < b[j]:
			if components[j] == 1:
				continue
			else:
				print('NO')
				done = True
				break
		if a[j] > b[j]:
			if components[j] == -1:
				continue
			else:
				print('NO')
				done = True
				break
	if done == False:
		print('YES')


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def main():
	for _ in range_n():
		n = getint()
		a = l_unpack()
		b = l_unpack()
		aux = [[False, False] for _ in range(n)]
		for i in range(1, n):
			aux[i] = aux[i - 1][:]
			if a[i - 1] == 1:
				aux[i][1] = True
			elif a[i - 1] == -1:
				aux[i][0] = True
		for i in range(n):
			if b[i] > a[i] and (not aux[i][1]):
				print('NO')
				break
			elif b[i] < a[i] and (not aux[i][0]):
				print('NO')
				break
		else:
			print('YES')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	pos = False
	neg = False
	for (x, y) in zip(a, b):
		if y > x and (not pos):
			print('NO')
			break
		elif y < x and (not neg):
			print('NO')
			break
		if x == 1:
			pos = True
		elif x == -1:
			neg = True
	else:
		print('YES')


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

def get_int():
	return int(sys.stdin.readline())

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def myceil(x, y):
	return (x + y - 1) // y

def Solution(a, b, n):
	if a[0] != b[0]:
		print('NO')
		return
	neg = -1
	pos = -1
	for i in range(n):
		if neg == -1 and a[i] < 0:
			neg = i
		if pos == -1 and a[i] > 0:
			pos = i
	flag = True
	for i in range(n - 1, -1, -1):
		if a[i] != b[i]:
			if a[i] < b[i] and pos != -1 and (pos < i) or (a[i] > b[i] and neg != -1 and (neg < i)):
				continue
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')

def main():
	for _ in range(get_int()):
		n = get_int()
		a = get_ints_in_list()
		b = get_ints_in_list()
		Solution(a, b, n)
main()


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	q = 0
	x1 = a.count(-1)
	x2 = a.count(1)
	while q < n:
		i = n - q - 1
		if a[i] == 1:
			x2 -= 1
		elif a[i] == -1:
			x1 -= 1
		if b[i] > a[i]:
			if x2 > 0:
				q += 1
			else:
				break
		elif b[i] < a[i]:
			if x1 > 0:
				q += 1
			else:
				break
		elif b[i] == a[i]:
			q += 1
	if q == n:
		print('YES')
	else:
		print('NO')


for testis in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	s = set()
	ans = 'YES'
	for i in range(n):
		if arr2[i] > arr1[i] and 1 not in s or (arr2[i] < arr1[i] and -1 not in s):
			ans = 'NO'
			break
		s.add(arr1[i])
	print(ans)


def get_cur_result(a, b, n, first_plus, first_minus):
	cur_res = 'YES'
	for i in range(0, n):
		if a[i] == b[i]:
			continue
		if a[i] < b[i]:
			if first_plus >= 0 and first_plus < i:
				continue
			else:
				cur_res = 'NO'
				break
		if a[i] > b[i]:
			if first_minus >= 0 and first_minus < i:
				continue
			else:
				cur_res = 'NO'
				break
	return cur_res

def get_first_element(arr, elem):
	for i in range(0, len(arr)):
		if arr[i] == elem:
			return i
	return -1
t = int(input())
results = []
for _ in range(0, t):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	if n == 1:
		if a[0] == b[0]:
			results.append('YES')
		else:
			results.append('NO')
		continue
	first_plus = get_first_element(a, 1)
	first_minus = get_first_element(a, -1)
	cur_res = get_cur_result(a, b, n, first_plus, first_minus)
	results.append(cur_res)
for e in results:
	print(e)


def can_you(arr1, arr2, answers):
	if arr1[0] != arr2[0]:
		answers.append('NO')
		return
	for i in range(len(arr1)):
		if arr1[i] == arr2[i]:
			continue
		else:
			if arr2[i] < 0:
				flag = 0
				for j in range(0, i):
					if arr1[j] < 0:
						flag = 1
						break
				if flag == 0:
					answers.append('NO')
					return
			if arr2[i] > 0:
				flag = 0
				for j in range(0, i):
					if arr1[j] > 0:
						flag = 1
						break
				if flag == 0:
					answers.append('NO')
					return
			if arr2[i] == 0:
				if arr1[i] > 0:
					flag = 0
					for j in range(0, i):
						if arr1[j] < 0:
							flag = 1
							break
					if flag == 0:
						answers.append('NO')
						return
			if arr2[i] == 0:
				if arr1[i] < 0:
					flag = 0
					for j in range(0, i):
						if arr1[j] > 0:
							flag = 1
							break
					if flag == 0:
						answers.append('NO')
						return
	answers.append('YES')
answers = []
n = int(input())
for _ in range(n):
	i_dont_need_it = input()
	arr1 = input().split()
	arr1 = [int(num) for num in arr1]
	arr2 = input().split()
	arr2 = [int(num) for num in arr2]
	can_you(arr1, arr2, answers)
for answer in answers:
	print(answer)


t = int(input())
s = []
for jjj in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q = 0
	f = set()
	for i in range(0, n):
		if b[i] > a[i]:
			if 1 not in f:
				s.append('NO')
				q = 1
				break
		if b[i] < a[i]:
			if -1 not in f:
				s.append('NO')
				q = 1
				break
		f.add(a[i])
	if q == 0:
		s.append('YES')
for i in s:
	print(i)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	for i in range(n - 1, -1, -1):
		d[a[i]] -= 1
		if a[i] == b[i]:
			continue
		if b[i] > a[i]:
			if d[1] != 0:
				continue
			else:
				print('NO')
				break
		elif d[-1] != 0:
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	one = a.index(1) if 1 in a else len(a)
	ngOne = a.index(-1) if -1 in a else len(a)
	for i in range(n):
		if a[i] != b[i]:
			diff = b[i] - a[i]
			if diff <= 0 and ngOne >= i:
				return 'NO'
			elif diff > 0 and one >= i:
				return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	print(main())


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
t = ip()
for _ in range(t):
	n = ip()
	a = list(inp())
	b = list(inp())
	dic = defaultdict(bool)
	flag = True
	for i in range(n):
		if i == 0:
			if a[i] == b[i]:
				dic[a[i]] = True
			else:
				flag = False
				break
		else:
			if a[i] < b[i]:
				if dic[1]:
					pass
				else:
					flag = False
					break
			elif a[i] == b[i]:
				pass
			elif dic[-1]:
				pass
			else:
				flag = False
				break
			dic[a[i]] = True
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	am = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	fl1 = False
	fl2 = False
	for i in range(am):
		if b[i] < a[i] and (not fl2):
			print('NO')
			break
		if b[i] > a[i] and (not fl1):
			print('NO')
			break
		if a[i] == 1:
			fl1 = True
		if a[i] == -1:
			fl2 = True
	else:
		print('YES')


def solve(a, b, n):
	l = [(False, False)]
	for e in a:
		l.append((l[-1][0] or e == -1, l[-1][1] or e == 1))
	for i in range(-1, -n - 1, -1):
		if a[i] < b[i]:
			if not l[i - 1][1]:
				print('NO')
				return
		elif a[i] > b[i]:
			if not l[i - 1][0]:
				print('NO')
				return
	print('YES')

def main():
	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()]
		solve(a, b, n)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	neg = 0
	pos = 0
	ans = True
	for i in range(n):
		if a[i] == b[i]:
			if a[i] > 0:
				pos += 1
			elif a[i] < 0:
				neg += 1
			continue
		if b[i] > 0:
			if pos == 0:
				ans = False
				break
		if b[i] < 0:
			if neg == 0:
				ans = False
				break
		if b[i] == 0:
			if a[i] < 0:
				if pos == 0:
					ans = False
					break
			elif neg == 0:
				ans = False
				break
		if a[i] > 0:
			pos += 1
		elif a[i] < 0:
			neg += 1
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(c) for c in input().split(' ')]
	b = [int(c) for c in input().split(' ')]
	count = 1
	pos = False
	neg = False
	for i in range(n):
		if b[i] > a[i] and pos == False:
			count = -1
		if b[i] < a[i] and neg == False:
			count = -1
		if a[i] == 1:
			pos = True
		if a[i] == -1:
			neg = True
	if count == -1:
		ans.append('NO')
	else:
		ans.append('YES')
for i in range(t):
	print(ans[i])


t = input()
t = int(t)
while t > 0:
	t -= 1
	n = input()
	n = int(n)
	a = input().split()
	b = input().split()
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	flag = 0
	mp = {1: 0, -1: 0}
	for i in range(n):
		res = b[i] - a[i]
		if res < 0 and mp[-1] == 0:
			flag = 1
			break
		if res > 0 and mp[1] == 0:
			flag = 1
			break
		mp[a[i]] = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 300010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def solve():
	n = int(input())
	a = arrIN()
	b = arrIN()
	x = [[0, 0, 0] for i in range(n)]
	for i in range(n):
		x[i][0] = int(a[i] == -1)
		x[i][1] = int(a[i] == 0)
		x[i][2] = int(a[i] == 1)
		x[i][0] |= x[i - 1][0]
		x[i][1] |= x[i - 1][1]
		x[i][2] |= x[i - 1][2]
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(1, n):
			if a[i] != b[i]:
				if a[i] > b[i]:
					if not x[i - 1][0]:
						print('NO')
						break
				elif not x[i - 1][2]:
					print('NO')
					break
		else:
			print('YES')
t = int(input())
for i in range(t):
	solve()


def solve(array_a, array_b):
	assert len(array_a) == len(array_b)
	canAdd = False
	canSubtract = False
	for i in range(len(array_a)):
		if array_a[i] < array_b[i] and (not canAdd):
			return False
		if array_a[i] > array_b[i] and (not canSubtract):
			return False
		canAdd = canAdd or array_a[i] == 1
		canSubtract = canSubtract or array_a[i] == -1
	return True
for i in range(int(input())):
	n = int(input())
	array_a = [int(x) for x in input().split()]
	array_b = [int(x) for x in input().split()]
	print('YES' if solve(array_a, array_b) else 'NO')


import sys, math, cmath, time
start_time = time.time()

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

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

def solve():
	n = inp()
	a = inlt()
	b = inlt()
	q = 0
	w = 0
	qw = 0
	for i in range(len(a)):
		if b[i] - a[i] > 0 and q != 1 or (b[i] - a[i] < 0 and w != 1):
			qw = 1
			break
		if a[i] == 1:
			q = 1
		if a[i] == -1:
			w = 1
	if qw == 0:
		print('YES')
	else:
		print('NO')
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
t = inp()
for tt in range(t):
	solve()
if not ONLINE_JUDGE:
	print('Time Elapsed:', time.time() - start_time, 'seconds')
sys.stdout.close()


def NO():
	return print('NO')

def YES():
	return print('YES')

def INT():
	return int(input())

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

def STR():
	return input()

def MAP():
	return map(int, input().split())
for x in range(INT()):
	n = INT()
	c = [0] * 3
	a = LIST()
	b = LIST()
	for i in range(n):
		c[a[i] + 1] += 1
	check = False
	for i in range(n - 1, -1, -1):
		c[a[i] + 1] -= 1
		if a[i] > b[i]:
			if c[0] == 0:
				check = True
		elif a[i] < b[i]:
			if c[2] == 0:
				check = True
	YES() if not check else NO()


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l):
	n = len(l)
T = int(input())
for _ in range(T):
	N = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	f = 1
	if a[0] != b[0]:
		f = 0
	check = set()
	for i in range(N):
		if a[i] != b[i]:
			diff = b[i] - a[i]
			f1 = 0
			for j in list(check):
				if diff >= 0 and j == 1:
					f1 = 1
					break
				if diff <= 0 and j == -1:
					f1 = 1
					break
			if not f1:
				f = 0
				break
		if a[i] != 0:
			check.add(a[i])
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'YES'
	dic = {}
	for i in range(n):
		if a[i] < b[i] and 1 not in dic or (a[i] > b[i] and -1 not in dic):
			ans = 'NO'
			break
		dic[a[i]] = True
	print(ans)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	one = -1
	mi = -1
	c = 0
	for i in range(n - 1, -1, -1):
		if a[i] < b[i]:
			if one == -1:
				if 1 not in a[:len(a) - (n - i)]:
					c = 1
					break
				else:
					one = a.index(1)
			elif i <= one:
				c = 1
				break
		elif a[i] > b[i]:
			if mi == -1:
				if -1 not in a[:len(a) - (n - i)]:
					c = 1
					break
				else:
					mi = a.index(-1)
			elif i <= mi:
				c = 1
				break
	if c == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	B = [int(a) for a in input().split()]
	plus = 0
	minus = 0
	g = 0
	for i in range(N):
		(a, b) = (A[i], B[i])
		d = b - a
		if d == 0 or (d > 0 and plus) or (d < 0 and minus):
			pass
		else:
			print('NO')
			break
		if a > 0:
			plus = 1
		if a < 0:
			minus = 1
	else:
		print('YES')


t = int(input())
for k in range(t):
	n = int(input())
	a = list([int(x) for x in input().split()])
	prev = [set()]
	for i in range(1, n):
		s = set()
		s.add(a[i - 1])
		s = s.union(prev[i - 1])
		prev.append(s)
	b = list([int(x) for x in input().split()])
	if a[0] != b[0]:
		print('NO')
		continue
	flag = True
	for j in range(1, n):
		if a[j] != b[j]:
			diff = b[j] - a[j]
			if diff > 0:
				if 1 in prev[j]:
					continue
				else:
					print('NO')
					flag = False
					break
			if diff < 0:
				if -1 in prev[j]:
					continue
				else:
					print('NO')
					flag = False
					break
	if flag:
		print('YES')


from math import ceil, gcd, floor
from collections import deque, defaultdict, Counter
from heapq import heappush as hpush, heappop as hpop, heapify
from functools import lru_cache
testcase = int(input())
for _ in range(testcase):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = defaultdict(lambda : set([0]))
	s = set([a[0]])
	d[0] = set([0])
	for i in range(1, len(a)):
		d[i] |= s
		s.add(a[i])
	f = 0
	for i in range(len(b)):
		diff = b[i] - a[i]
		if diff < 0:
			if -1 not in d[i]:
				f = 1
				break
		elif diff > 0:
			if 1 not in d[i]:
				f = 1
				break
	if f == 1:
		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()))
	flag3 = 1
	flag1 = 0
	flag2 = 0
	for i in range(n):
		if i == 0:
			if a[0] != b[0]:
				print('NO')
				flag3 = 0
				break
		else:
			if flag1 == 0:
				if a[i - 1] == 1:
					flag1 = 1
			if flag2 == 0:
				if a[i - 1] == -1:
					flag2 = 1
		if flag1 and flag2:
			print('YES')
			flag3 = 0
			break
		elif b[i] - a[i] > 0 and flag1 != 1:
			print('NO')
			flag3 = 0
			break
		elif b[i] - a[i] < 0 and flag2 != 1:
			print('NO')
			flag3 = 0
			break
	if flag3:
		print('YES')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pref = [(0, 0)]
	for i in range(n):
		if a[i] == -1:
			pref.append((1, pref[-1][1]))
		elif a[i] == 1:
			pref.append((pref[-1][0], 1))
		else:
			pref.append(pref[-1])
	check = True
	for i in range(n - 1, -1, -1):
		if a[i] > b[i]:
			if not pref[i][0]:
				check = False
				break
		elif a[i] < b[i]:
			if not pref[i][1]:
				check = False
				break
	if check:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	x = [int(g) for g in input().split(' ')]
	y = [int(g) for g in input().split(' ')]
	seen = set()
	count = 0
	no = 0
	for (a, b) in zip(x, y):
		if a != b:
			if a > b:
				if -1 not in seen:
					print('NO')
					no = 1
					break
			elif 1 not in seen:
				print('NO')
				no = 1
				break
		seen.add(a)
	if not no:
		print('YES')


def main_function():
	for t in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[0] != b[0]:
			print('NO')
			continue
		try:
			plus = a.index(1)
		except ValueError:
			plus = n
		try:
			minus = a.index(-1)
		except ValueError:
			minus = n
		for i in range(1, n):
			if a[i] > b[i] and i <= minus or (a[i] < b[i] and i <= plus):
				print('NO')
				break
		else:
			print('YES')
			continue
main_function()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	cnt1 = 0
	cntn1 = 0
	for i in range(n):
		if a[i] == 1:
			cnt1 += 1
		if a[i] == -1:
			cntn1 += 1
	flag = 0
	for i in range(n - 1, -1, -1):
		if a[i] == 1:
			cnt1 -= 1
		if a[i] == -1:
			cntn1 -= 1
		if a[i] != b[i]:
			if (b[i] - a[i] < 0 or cnt1 <= 0) and (b[i] - a[i] > 0 or cntn1 <= 0):
				print('NO')
				flag = 1
				break
	if flag == 0:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	broken = False
	seen = []
	for i in range(n):
		if sorted(seen) == [-1, 0, 1]:
			break
		if a[i] != b[i]:
			if a[i] > b[i]:
				if -1 not in seen:
					broken = True
					break
			elif 1 not in seen:
				broken = True
				break
		if a[i] not in seen:
			seen.append(a[i])
	if broken:
		print('NO')
	else:
		print('YES')


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	pos = -2
	neg = -2
	if a[0] > 0:
		pos = 1
	elif a[0] < 0:
		neg = 1
	av = []
	for i in range(1, n):
		av.append((pos, neg))
		if a[i] > 0:
			pos = 1
		elif a[i] < 0:
			neg = 1
	if a[0] != b[0]:
		print('NO')
		continue
	f = 0
	for i in range(1, n):
		x = av[i - 1]
		(pos, neg) = (x[0], x[1])
		if b[i] == a[i]:
			continue
		elif b[i] > a[i]:
			if pos == 1:
				continue
			else:
				f = 1
				break
		elif b[i] < a[i]:
			if neg == 1:
				continue
			else:
				f = 1
				break
	if f == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	f = False
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	used = [0] * 3
	for i in range(n):
		if a[i] != b[i]:
			if b[i] > a[i] and used[2] == 0:
				f = True
				break
			elif b[i] < a[i] and used[0] == 0:
				f = True
				break
		used[a[i] + 1] = 1
	if f:
		print('NO')
	else:
		print('YES')


from sys import stdin
input = 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()]
	flag = 'YES'
	s = set()
	if a[0] != b[0]:
		flag = 'NO'
	s.add(a[0])
	for x in range(1, n):
		if a[x] == b[x]:
			s.add(a[x])
			continue
		elif a[x] > b[x]:
			if -1 not in s:
				flag = 'NO'
				break
			else:
				s.add(a[x])
		elif 1 not in s:
			flag = 'NO'
			break
		else:
			s.add(a[x])
	print(flag)


import sys

def main():
	res = ''
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		sub_res = 'NO\n'
		if a[0] == b[0]:
			sub_res = 'YES\n'
			up = False
			down = False
			for i in range(n):
				if b[i] > a[i]:
					if not up:
						sub_res = 'NO\n'
						break
				if b[i] < a[i]:
					if not down:
						sub_res = 'NO\n'
						break
				if a[i] == 1:
					up = True
				elif a[i] == -1:
					down = True
				if up and down:
					break
		res += sub_res
	print(res)
main()


for _ in range(int(input())):
	n = int(input())
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	plus = False
	minus = False
	for i in range(n):
		ok = False
		if plus:
			if b[i] > a[i]:
				ok = True
		if minus:
			if b[i] < a[i]:
				ok = True
		if b[i] == a[i]:
			ok = True
		if not plus and a[i] == 1:
			plus = True
		if not minus and a[i] == -1:
			minus = True
		if not ok:
			break
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	w = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	r = set()
	for i in range(w):
		q = a[i] - b[i]
		if q == 0:
			r.add(a[i])
		elif q < 0:
			if 1 not in r:
				w = -1
				break
			else:
				r.add(a[i])
		elif -1 not in r:
			w = -1
			break
		else:
			r.add(a[i])
	if w == -1:
		print('NO')
	else:
		print('YES')


t = int(input())
for k in range(t):
	n = int(input())
	a = [int(el) for el in input().split()]
	b = [int(el) for el in input().split()]
	otr = False
	pol = False
	bad = False
	for i in range(n):
		if b[i] < a[i] and (not otr):
			bad = True
		if b[i] > a[i] and (not pol):
			bad = True
		if a[i] < 0:
			otr = True
		if a[i] > 0:
			pol = True
	if bad:
		print('NO')
	else:
		print('YES')


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(plus_bit, minus_bit) = (0, 0)
	bit = 0
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] > b[i]:
			if minus_bit == 0:
				bit = 1
				break
		elif plus_bit == 0:
			bit = 1
			break
		if a[i] == 1:
			plus_bit = 1
		elif a[i] == -1:
			minus_bit = 1
	if bit:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
input = stdin.readline

def A():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		print('W' + 'B' * (m - 1))
		for i in range(1, n):
			print('B' * m)

def B():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		foundNeg = False
		foundPos = False
		succ = True
		for i in range(n):
			if a[i] > b[i]:
				if not foundNeg:
					succ = False
					break
			elif a[i] < b[i]:
				if not foundPos:
					succ = False
					break
			if a[i] > 0:
				foundPos = True
			elif a[i] < 0:
				foundNeg = True
		if succ:
			print('YES')
		else:
			print('NO')
	return

def C():
	return

def D():
	return
B()


for _ in range(int(input())):
	num = int(input())
	sett = [int(x) for x in input().split()]
	ans = [int(x) for x in input().split()]
	mset = set()
	answer = 'YES'
	for i in range(num):
		if ans[i] > sett[i] and 1 not in mset or (sett[i] > ans[i] and -1 not in mset):
			answer = 'NO'
			break
		mset.add(sett[i])
	print(answer)


def answer(a, b):
	if a[0] != b[0]:
		return 'NO'
	aHasPlus = False
	aHasMinus = False
	for i in range(len(b)):
		if a[i] == b[i]:
			continue
		if a[i] < b[i]:
			if aHasPlus is False:
				for j in range(i - 1, -1, -1):
					if a[j] > 0:
						aHasPlus = True
						break
			if aHasPlus is False:
				return 'NO'
		if a[i] > b[i]:
			if aHasMinus is False:
				for j in range(i - 1, -1, -1):
					if a[j] < 0:
						aHasMinus = True
						break
			if aHasMinus is False:
				return 'NO'
	return 'YES'
testCount = int(input())
for _ in range(testCount):
	n = input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(answer(a, b))


T = int(input())
ans = []
for t in range(T):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	A = {}
	for i in range(1, n):
		A[i] = A.get(i - 1, set()) | {a[i - 1]}
	i = 0
	yes = True
	while i < n and yes:
		d = b[i] - a[i]
		if d > 0 and 1 not in A.get(i, {0}) or (d < 0 and -1 not in A.get(i, {0})):
			yes = False
			ans.append('NO')
		i += 1
	if yes:
		ans.append('YES')
for a in ans:
	print(a)


from math import *
from sys import *
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()))
	m = []
	x = []
	c = 0
	for i in range(n):
		m.append(c)
		if a[i] == 1:
			if 1 not in x:
				x.append(1)
				c += 1
		elif a[i] == -1:
			if -1 not in x:
				x.append(-1)
				c += 4
	f = 0
	for i in range(n):
		if b[i] > a[i]:
			if m[i] == 0 or m[i] == 4:
				f = 1
				break
		if b[i] < a[i]:
			if m[i] < 4:
				f = 1
				break
	if f == 0:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	possibleFlag = True
	posBumpFlag = False
	negBumpFlag = False
	for i in range(0, n):
		if a[i] != b[i]:
			if a[i] < b[i] and posBumpFlag == False:
				possibleFlag = False
			if a[i] > b[i] and negBumpFlag == False:
				possibleFlag = False
		if a[i] > 0:
			posBumpFlag = True
		elif a[i] < 0:
			negBumpFlag = True
	print('YES' if possibleFlag else 'NO')
t = int(input())
while t > 0:
	t -= 1
	solve()


t = int(input())
while t:
	n = int(input())
	s = input().split()
	a = [int(i) for i in s]
	s = input().split()
	b = [int(i) for i in s]
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		elif a[i] < b[i]:
			try:
				it = a.index(1)
				if it < i:
					continue
				elif it >= i:
					print('NO')
					break
			except ValueError:
				print('NO')
				break
		elif a[i] > b[i]:
			try:
				it = a.index(-1)
				if it < i:
					continue
				elif it >= i:
					print('NO')
					break
			except ValueError:
				print('NO')
				break
	else:
		print('YES')
	t -= 1


from sys import stdin, stdout
import traceback
import math
import bisect
from typing import List, Tuple
import itertools as it
read = lambda : stdin.readline().strip()
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

def enumerate_sorted(iterable):
	return sorted(zip(it.count(), iterable), key=lambda x: x[1])

class Sol:

	def __init__(self, n, aa, bb):
		self.n = n
		self.aa = aa
		self.bb = bb

	@classmethod
	def input(cls):
		n = int(read())
		aa = reads()
		bb = reads()
		return cls(n, aa, bb)

	def solve(self):
		has_plus_1 = False
		has_neg_1 = False
		for (i, (a, b)) in enumerate(zip(self.aa, self.bb)):
			diff = b - a
			if diff > 0 and (not has_plus_1):
				return False
			elif diff < 0 and (not has_neg_1):
				return False
			if a > 0:
				has_plus_1 = True
			if a < 0:
				has_neg_1 = True
		return True
try:
	t = int(read())
	for _ in range(t):
		res = Sol.input().solve()
		writeln('YES' if res else 'NO')
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


import sys

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

def N():
	return int(input())
for _ in range(N()):
	n = N()
	arra = list(RL())
	arrb = list(RL())
	rec = set()
	res = True
	for i in range(n):
		if arra[i] != arrb[i]:
			dif = arrb[i] - arra[i]
			if dif > 0:
				if 1 not in rec:
					res = False
					break
			elif dif < 0:
				if -1 not in rec:
					res = False
					break
		rec.add(arra[i])
	print('YES' if res else 'NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	no = -1
	po = -1
	z = -1
	for i in range(n):
		if lst1[i] == -1 and no == -1:
			no = i
		elif lst1[i] == 0 and z == -1:
			z = i
		elif lst1[i] == 1 and po == -1:
			po = i
	f = True
	for i in range(n):
		if lst1[i] > lst2[i]:
			if no < i and no != -1:
				continue
			else:
				f = False
				break
		if lst1[i] < lst2[i]:
			if po < i and po != -1:
				continue
			else:
				f = False
				break
	if f == False:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	s = set()
	ans = True
	for i in range(n):
		if a[i] == b[i] or (b[i] < a[i] and -1 in s) or (b[i] > a[i] and 1 in s):
			s.add(a[i])
			continue
		else:
			ans = False
			break
	print('YES' if ans else 'NO')


def main():
	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()]
		counters = {-1: 0, 1: 0, 0: 0}
		for el in a:
			counters[el] += 1
		answer = 'YES'
		for i in range(n - 1, 0, -1):
			key = a[i]
			counters[key] -= 1
			if b[i] > a[i]:
				if counters[1] <= 0:
					answer = 'NO'
					break
			elif b[i] < a[i]:
				if counters[-1] <= 0:
					answer = 'NO'
					break
		if a[0] != b[0]:
			answer = 'NO'
		print(answer)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	updown = []
	for i in range(n):
		if b[i] > a[i]:
			updown.append(1)
		elif b[i] < a[i]:
			updown.append(-1)
		else:
			updown.append(0)
	pos = []
	neg = []
	pi = None
	ni = None
	for i in range(n):
		if pi != None:
			pos.append(pi)
		else:
			pos.append(None)
		if a[i] > 0:
			pi = i
		if ni != None:
			neg.append(ni)
		else:
			neg.append(None)
		if a[i] < 0:
			ni = i
	final = True
	for i in range(n):
		if updown[i] > 0:
			if pos[i] != None:
				if pos[i] < i:
					final = final and True
			else:
				final = final and False
		if updown[i] == 0:
			final = final and True
		if updown[i] < 0:
			if neg[i] != None:
				if neg[i] < i:
					final = final and True
			else:
				final = final and False
	if final:
		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()))
	x = 0
	y = 0
	flag = 0
	if n == 1:
		if a[0] == b[0]:
			print('YES')
		else:
			print('NO')
		continue
	for i in range(n):
		if a[i] > b[i] and y == 0:
			flag = 1
			break
		if a[i] < b[i] and x == 0:
			flag = 1
			break
		if a[i] == 1:
			x = 1
		if a[i] == -1:
			y = 1
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(a) for a in input().split()]
	b = [int(b) for b in input().split()]
	true = 1
	big = [-1, 0]
	less = [-1, 0]
	for i in range(n):
		if a[i] is 1:
			if big[0] is -1:
				big[0] = i
				big[1] = 1
			else:
				pass
		elif a[i] is -1:
			if less[0] is -1:
				less[0] = i
				less[1] = 1
			else:
				pass
	for j in range(n):
		if a[j] is b[j]:
			pass
		elif a[j] < b[j]:
			if big[1] is 0:
				print('NO')
				true = 0
				break
			elif j > big[0]:
				pass
			else:
				print('NO')
				true = 0
				break
		elif less[1] is 0:
			print('NO')
			true = 0
			break
		elif j > less[0]:
			pass
		else:
			print('NO')
			true = 0
			break
	if true is 1:
		print('YES')


from collections import Counter, defaultdict
from math import factorial as fact

def solve(n, a, b):
	dec = False
	inc = False
	for j in range(n):
		if not dec and (not inc):
			if a[j] != b[j]:
				print('NO')
				return
		if b[j] > a[j] and (not inc):
			print('NO')
			return
		if b[j] < a[j] and (not dec):
			print('NO')
			return
		if a[j] == 1:
			inc = True
		if a[j] == -1:
			dec = True
		if inc and dec:
			print('YES')
			return
	print('YES')
t = int(input())
for i in range(t):
	nn = int(input())
	aa = [int(x) for x in input().split()]
	bb = [int(x) for x in input().split()]
	solve(nn, aa, bb)


t = int(input())
for i in range(t):
	s = 'YES'
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = 0
	c1 = 0
	c2 = 0
	for i in range(0, len(a)):
		if b[i] > a[i] and c1 == 0:
			s = 'NO'
			break
		elif b[i] < a[i] and c2 == 0:
			s = 'NO'
			break
		elif a[i] == 1:
			c1 = 1
		elif a[i] == -1:
			c2 = 1
	print(s)


def f():
	input()
	first = []
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(len(a)):
		d = b[i] - a[i]
		if d == 0 or (d > 0 and 1 in first) or (d < 0 and -1 in first):
			pass
		else:
			return False
		if a[i] not in first:
			first += [a[i]]
	return True
for i in range(int(input())):
	print('YES' if f() else 'NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = neg = False
	ok = True
	for i in range(n):
		if a[i] > b[i] and (not neg):
			ok = False
			break
		if a[i] < b[i] and (not pos):
			ok = False
			break
		if a[i] == -1:
			neg = True
		if a[i] == 1:
			pos = True
	print('YES' if ok else 'NO')


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	p = ne = 0
	f = True
	for i in range(n):
		if l1[i] != l2[i]:
			if l1[i] < l2[i] and p == 0:
				f = False
			if l1[i] > l2[i] and ne == 0:
				f = False
		if l1[i] < 0:
			ne += 1
		if l1[i] > 0:
			p += 1
	if f == False:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = set()
	flag = True
	for i in range(n):
		if a[i] > b[i] and -1 not in p or (a[i] < b[i] and 1 not in p):
			flag = False
		p.add(a[i])
	print('YES') if flag else print('NO')


num_c = int(input())
for i in range(num_c):
	dummy = input()
	first_zero = 99999999999
	first_1 = 99999999999
	first_minus = 99999999999
	fnum = 0
	fz = 0
	fmin = 0
	a = input().split()
	for (index, num) in enumerate(a):
		a[index] = int(num)
		if a[index] == 1 and fnum == 0:
			first_1 = index
			fnum = 1
		elif a[index] == 0 and fz == 0:
			first_zero == index
			fz = 1
		elif a[index] == -1 and fmin == 0:
			first_minus = index
			fmin = 1
	b = input().split()
	for (index, num) in enumerate(b):
		b[index] = int(num)
	no = 0
	for i in range(len(a)):
		if i == 0:
			if a[i] != b[i]:
				print('NO')
				no = 1
				break
		if a[i] != b[i]:
			if a[i] > b[i] and first_minus >= i or (a[i] < b[i] and first_1 >= i):
				print('NO')
				no = 1
				break
	if no == 0:
		print('YES')


n = int(input())
for h in range(0, n):
	o = int(input())
	p = input().rstrip().split(' ')
	q = input().rstrip().split(' ')
	ne = 0
	ze = 0
	G = 0
	po = 0
	for i in range(0, len(p)):
		if int(p[i]) < 0:
			ne += 1
		if int(p[i]) == 0:
			ze += 1
		if int(p[i]) > 0:
			po += 1
	for i in range(len(q) - 1, -1, -1):
		if int(p[i]) == 0:
			ze -= 1
		elif int(p[i]) > 0:
			po -= 1
		else:
			ne -= 1
		if int(q[i]) == int(p[i]):
			continue
		elif int(q[i]) < int(p[i]):
			if ne >= 1:
				continue
			else:
				G = 1
				break
		elif int(q[i]) > int(p[i]):
			if po >= 1:
				continue
			else:
				G = 1
				break
	if G == 0:
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def solve():
	n = int(input().strip())
	A = [int(s) for s in input().strip().split()]
	B = [int(s) for s in input().strip().split()]
	cnt = [0] * 3
	for a in A:
		cnt[a] += 1
	for (a, b) in zip(A[::-1], B[::-1]):
		cnt[a] -= 1
		if b > a and cnt[1] == 0 or (b < a and cnt[-1] == 0):
			print('NO')
			return
	print('YES')

def main():
	for _ in range(int(input().strip())):
		solve()
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def is_poss(a, b):
	firsts = [-1, -1]
	needs = 2
	for (c, el) in enumerate(a):
		if el == 1 and firsts[0] == -1:
			needs -= 1
			firsts[0] = c
		elif el == -1 and firsts[1] == -1:
			needs -= 1
			firsts[1] = c
		if needs == 0:
			break
	if firsts[0] == -1:
		firsts[0] = len(a)
	if firsts[1] == -1:
		firsts[1] = len(a)
	for (c, el) in enumerate(b):
		if el > 1:
			if c <= firsts[0]:
				return False
		elif el == 1:
			if c < firsts[0]:
				return False
		elif el == 0:
			if a[c] == 0:
				continue
			elif a[c] > 0:
				if c < firsts[1]:
					return False
			elif c < firsts[0]:
				return False
		elif el == -1:
			if c < firsts[1]:
				return False
		elif c <= firsts[1]:
			return False
	return True
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if is_poss(a, b):
		print('YES')
	else:
		print('NO')


t = int(input())
resultList = []
for _ in range(t):
	countPos1 = 0
	countNeg1 = 0
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = True
	for i in range(n):
		if b[i] > a[i] and countPos1 == 0:
			flag = False
			break
		elif b[i] < a[i] and countNeg1 == 0:
			flag = False
			break
		if a[i] == 1:
			countPos1 += 1
		elif a[i] == -1:
			countNeg1 += 1
	if flag == True:
		resultList.append('YES')
	else:
		resultList.append('NO')
for x in resultList:
	print(x)


from sys import stdin

def func(n):
	a = n * (n + 1)
	b = n + n + 1
	return a * b // 6
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	flag = 0
	d = {1: -1, -1: -1}
	count = 0
	for i in range(n):
		if a[i] == 1 and d[1] == -1:
			d[1] = i
			count += 1
		elif a[i] == -1 and d[-1] == -1:
			d[-1] = i
			count += 1
		if count == 2:
			break
	for i in range(n - 1, -1, -1):
		if b[i] != a[i]:
			if b[i] > a[i]:
				if d[1] >= i or d[1] == -1:
					flag = 1
					break
			elif d[-1] >= i or d[-1] == -1:
				flag = 1
				break
	if flag == 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()))
	minus_1 = False
	plus_1 = False
	check = True
	for i in range(n):
		dif = b[i] - a[i]
		if dif == 0:
			pass
		elif dif > 0:
			if not plus_1:
				check = False
				break
		elif not minus_1:
			check = False
			break
		if a[i] == 1:
			plus_1 = True
		elif a[i] == -1:
			minus_1 = True
	if check:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	p = 0
	d = {}
	for i in range(len(k)):
		if k[i] > l[i] and 1 not in d:
			print('NO')
			p = 1
			break
		elif k[i] < l[i] and -1 not in d:
			print('NO')
			p = 1
			break
		elif l[i] not in d:
			d[l[i]] = 1
	if p == 0:
		print('YES')


from sys import stdin, stdout
import math
import heapq
t = 1

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

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

def fint():
	return list(map(int, stdin.readline().split()))

def main():
	n = aint()
	a = lint()
	b = lint()
	first1 = n
	firstm1 = n
	for i in range(n):
		if a[i] == 1:
			first1 = i
			break
	for i in range(n):
		if a[i] == -1:
			firstm1 = i
			break
	for i in range(n - 1, -1, -1):
		if a[i] == b[i]:
			continue
		if a[i] > b[i] and firstm1 < i:
			continue
		if a[i] < b[i] and first1 < i:
			continue
		print('NO')
		return
	print('YES')
t = int(input())
for i in range(t):
	main()


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	n1 = 0
	n2 = 0
	res = 1
	for i in range(n):
		if b[i] > a[i] and n1 > 0:
			if a[i] == 1:
				n1 += 1
			if a[i] == -1:
				n2 += 1
		elif b[i] > a[i] and n1 == 0:
			if a[i] == 1:
				n1 += 1
			if a[i] == -1:
				n2 += 1
			res = 0
			break
		elif b[i] < a[i] and n2 > 0:
			if a[i] == 1:
				n1 += 1
			if a[i] == -1:
				n2 += 1
		elif b[i] < a[i] and n2 == 0:
			if a[i] == 1:
				n1 += 1
			if a[i] == -1:
				n2 += 1
			res = 0
			break
		else:
			if a[i] == 1:
				n1 += 1
			if a[i] == -1:
				n2 += 1
	if res:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 1
	minusone = n
	zero = n
	one = n
	for i in range(0, n):
		if a[i] == 0:
			zero = i
			break
	for i in range(0, n):
		if a[i] == 1:
			one = i
			break
	for i in range(0, n):
		if a[i] == -1:
			minusone = i
			break
	for i in range(0, n):
		if a[i] == b[i]:
			continue
		elif a[i] > b[i]:
			if minusone >= i:
				ans = 0
				break
		elif a[i] < b[i]:
			if one >= i:
				ans = 0
				break
	if ans == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(neg1, pos1, zero) = (0, 0, 0)
	ook = 1
	for i in range(n):
		tag = 0
		if a[i] == b[i]:
			tag = 1
		if a[i] > b[i] and neg1:
			tag = 1
		if a[i] < b[i] and pos1:
			tag = 1
		if tag == 0:
			ook = 0
			break
		if a[i] == 1:
			pos1 = 1
		if a[i] == -1:
			neg1 = 1
	if ook:
		print('YES')
	else:
		print('NO')


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	p = set()
	ans = 'YES'
	for i in range(n):
		if a[i] != b[i] and (b[i] - a[i]) // abs(b[i] - a[i]) not in p:
			ans = 'NO'
			break
		else:
			p.add(a[i])
	print(ans)


tt = int(input())
while tt:
	n = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	C = []
	for i in range(0, n):
		c = A[i] - B[i]
		C.append(c)
	flag_p = False
	flag_n = False
	ans = False
	ii = 0
	for x in A:
		if C[ii] < 0 and flag_p is False:
			ans = True
			print('NO')
			break
		if C[ii] > 0 and flag_n is False:
			ans = True
			print('NO')
			break
		if x == 1:
			flag_p = True
		elif x == -1:
			flag_n = True
		ii += 1
	if ans is False:
		print('YES')
	tt -= 1


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in inp().strip().split()]
	b = [int(x) for x in inp().strip().split()]
	oneExists = False
	negExists = False
	if a[0] != b[0]:
		print('NO')
		continue
	for i in range(len(a)):
		if b[i] > a[i] and (not oneExists):
			print('NO')
			break
		if b[i] < a[i] and (not negExists):
			print('NO')
			break
		if a[i] == 1:
			oneExists = True
		elif a[i] == -1:
			negExists = True
	else:
		print('YES')


N = int(input())
for _ in range(N):
	K = int(input())
	A = map(int, input().split())
	B = map(int, input().split())
	have_1 = False
	have_m1 = False
	res = []
	for (u, v) in zip(A, B):
		if u == v:
			res.append(True)
		elif u > v and have_m1:
			res.append(True)
		elif u < v and have_1:
			res.append(True)
		else:
			res.append(False)
		if u == 1:
			have_1 = True
		if u == -1:
			have_m1 = True
	if all(res):
		print('YES')
	else:
		print('NO')


def kind(a, b):
	on = False
	minon = False
	if a[0] != b[0]:
		return 'NO'
	for i in range(len(a)):
		if a[i] == b[i]:
			if a[i] == 1:
				on = True
			elif a[i] == -1:
				minon = True
		elif a[i] > b[i]:
			if minon:
				if a[i] == 1:
					on = True
			else:
				return 'NO'
		elif on:
			if a[i] == -1:
				minon = True
		else:
			return 'NO'
	return 'YES'
t = int(input())
l = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l.append([a, b])
for j in l:
	print(kind(j[0], j[1]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = neg = -1
	flag = 1
	for i in range(n):
		if a[i] > b[i] and neg == -1:
			flag = 0
		if a[i] < b[i] and pos == -1:
			flag = 0
		if a[i] > 0:
			pos = i
		if a[i] < 0:
			neg = i
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	i = 0
	pos_add = n + 1
	pos_sub = n + 1
	while i < n:
		if a[i] == 1 and pos_add == n + 1:
			pos_add = i
		elif a[i] == -1 and pos_sub == n + 1:
			pos_sub = i
		i += 1
	i = 0
	boola = 1
	while i < n:
		if a[i] < b[i] and i <= pos_add:
			boola = 0
			break
		elif a[i] > b[i] and i <= pos_sub:
			boola = 0
			break
		i += 1
	if boola:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(o, m) = (10 ** 8, 10 ** 8)
	for i in range(n):
		if a[i] == 1 and o == 10 ** 8:
			o = i
		if a[i] == -1 and m == 10 ** 8:
			m = i
	for i in range(n):
		if a[i] != b[i]:
			if b[i] > a[i] and o < i:
				a[i] = b[i]
			if b[i] < a[i] and m < i:
				a[i] = b[i]
	if a == b:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	A = map(int, input().split())
	B = map(int, input().split())
	seen_pos = seen_neg = False
	for (a, b) in zip(A, B):
		if b > a and (not seen_pos) or (b < a and (not seen_neg)):
			print('NO')
			break
		if a > 0:
			seen_pos = True
		elif a < 0:
			seen_neg = True
	else:
		print('YES')


import sys
input = sys.stdin.buffer.readline
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()]
	minIncreaseIndex = n
	minDecreaseIndex = n
	for i in range(n - 1, -1, -1):
		if a[i] == 1:
			minIncreaseIndex = i + 1
		if a[i] == -1:
			minDecreaseIndex = i + 1
	ok = True
	for i in range(n):
		if a[i] < b[i] and i < minIncreaseIndex:
			ok = False
			break
		if a[i] > b[i] and i < minDecreaseIndex:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


T = int(input())
for caseID in range(1, T + 1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(plus, minus) = (False, False)
	ans = True
	for i in range(n):
		if a[i] > b[i]:
			if not minus:
				ans = False
				break
		elif a[i] < b[i]:
			if not plus:
				ans = False
				break
		if a[i] > 0:
			plus = True
		elif a[i] < 0:
			minus = True
	print('YES' if ans else 'NO')


import math
for i in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	one = set()
	for j in range(0, len(b)):
		if a[j] == b[j]:
			one.add(a[j])
			continue
		if (a[j] != b[j]) & (j == 0):
			flag = 1
		elif a[j] < b[j]:
			if not 1 in one:
				flag = 1
		elif not -1 in one:
			flag = 1
		one.add(a[j])
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
out = ''
while t > 0:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	has_positive = False
	has_negative = False
	for i in range(n):
		if b[i] < a[i]:
			if not has_negative:
				out += 'NO\n'
				break
		elif b[i] > a[i]:
			if not has_positive:
				out += 'NO\n'
				break
		if a[i] == 1:
			has_positive = True
		elif a[i] == -1:
			has_negative = True
	else:
		out += 'YES\n'
print(out)


import sys
input = sys.stdin.readline
from math import *
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	p = 0
	m = 0
	flag = 0
	for i in range(n):
		if a[i] == b[i]:
			p += int(a[i] > 0)
			m += int(a[i] < 0)
		elif a[i] < b[i]:
			if p == 0:
				flag = 1
				break
		elif m == 0:
			flag = 1
			break
		p += int(a[i] > 0)
		m += int(a[i] < 0)
	print('YES' if flag == 0 else 'NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	neg = False
	pos = False
	flag = True
	for i in range(len(a)):
		if not pos and b[i] > a[i]:
			flag = False
		if not neg and b[i] < a[i]:
			flag = False
		if a[i] == 1:
			pos = True
		if a[i] == -1:
			neg = True
	if flag:
		print('YES')
	else:
		print('NO')


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


test = int(input())
for _ in range(test):
	ans = False
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	good = [0, 0]
	for i in range(n):
		if A[i] < B[i]:
			if good[0] == 0:
				print('NO')
				ans = True
				break
		elif A[i] > B[i]:
			if good[1] == 0:
				ans = True
				print('NO')
				break
		if A[i] == 1:
			good[0] = 1
		elif A[i] == -1:
			good[1] = 1
	if not ans:
		print('YES')


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	(p, m) = (0, 0)
	ans = 'YES'
	for i in range(n):
		if a[i] == b[i]:
			if a[i] == 1:
				p = 1
			elif a[i] == -1:
				m = 1
		elif a[i] > b[i]:
			if m == 0:
				ans = 'NO'
				break
			elif a[i] == 1:
				p = 1
		elif a[i] < b[i]:
			if p == 0:
				ans = 'NO'
				break
			elif a[i] == -1:
				m = 1
	print(ans)


t = int(input())
while t:
	t -= 1
	f = int(input())
	l1 = list(map(int, input().rstrip().split(' ')))
	l2 = list(map(int, input().rstrip().split(' ')))
	check_pos = False
	check_neg = False
	r = 'YES'
	for i in range(f):
		if l2[i] > l1[i] and (not check_pos):
			if 1 in l1[0:i]:
				check_pos = True
			else:
				r = 'NO'
				break
		elif l2[i] < l1[i] and (not check_neg):
			if -1 in l1[0:i]:
				check_neg = True
			else:
				r = 'NO'
				break
	print(r)


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	a = I()
	b = I()
	p = m = 0
	for i in range(n):
		if a[i] == 1:
			p += 1
		if a[i] == -1:
			m += 1
	f = 1
	for i in range(n - 1, -1, -1):
		if a[i] == 1:
			p -= 1
		if a[i] == -1:
			m -= 1
		if a[i] != b[i]:
			k = b[i] - a[i]
			if k > 0 and p > 0 or (k < 0 and m > 0):
				pass
			else:
				f = 0
				break
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	data1 = input().split()
	data2 = input().split()
	a = []
	b = []
	for i in range(n):
		a.append(int(data1[i]))
		b.append(int(data2[i]))
	x = n - 1
	y = n - 1
	count = 0
	for i in range(n):
		if a[i] == 1:
			x = i
			break
	for i in range(n):
		if a[i] == -1:
			y = i
			break
	for i in range(n):
		if b[i] - a[i] > 0:
			if i <= x:
				print('NO')
				count = 1
				break
		elif b[i] - a[i] < 0:
			if i <= y:
				print('NO')
				count = 1
				break
	if count == 0:
		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()))
	firstn = n
	if -1 in a:
		firstn = a.index(-1)
	firstp = n
	if 1 in a:
		firstp = a.index(1)
	works = 1
	if a[0] != b[0]:
		works = 0
	for j in range(n - 1, 0, -1):
		diff = b[j] - a[j]
		if diff > 0 and j <= firstp:
			works = 0
		if diff < 0 and j <= firstn:
			works = 0
	if works == 1:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	plus = True if a[0] == 1 else False
	minus = True if a[0] == -1 else False
	for i in range(1, n):
		if a[i] < b[i]:
			if plus == False:
				print('NO')
				break
		elif a[i] > b[i]:
			if minus == False:
				print('NO')
				break
		plus = True if a[i] == 1 else plus
		minus = True if a[i] == -1 else minus
	else:
		print('YES')


t = int(input())
for tc in range(t):
	n = int(input())
	a = input().split()
	b = input().split()
	if a[0] != b[0]:
		print('NO')
	else:
		i1 = n + 1
		i2 = n + 1
		l1 = 0
		l2 = 0
		for k in range(n):
			if int(a[k]) == -1 and l1 == 0:
				i1 = k
				l1 += 1
			elif int(a[k]) == 1 and l2 == 0:
				i2 = k
				l2 += 1
			if l1 == 1 and l2 == 1:
				break
		f1 = 0
		for i in range(n - 1, 0, -1):
			if int(a[i]) > int(b[i]):
				if i1 < i:
					pass
				else:
					print('NO')
					f1 = 1
					break
			elif int(a[i]) < int(b[i]):
				if i2 < i:
					pass
				else:
					print('NO')
					f1 = 1
					break
		if f1 == 0:
			print('YES')


n_cases = int(input())
for case_num in range(1, n_cases + 1):
	n = int(input())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	cmp_arr = [0] * n
	op_arr = [[False, False] for _ in range(n)]
	for i in range(1, n):
		op_arr[i][0] = op_arr[i - 1][0]
		op_arr[i][1] = op_arr[i - 1][1]
		if arr1[i - 1] == -1:
			op_arr[i][0] = True
		elif arr1[i - 1] == 1:
			op_arr[i][1] = True
	ok = True
	for i in range(n):
		if arr2[i] < arr1[i]:
			if not op_arr[i][0]:
				ok = False
				break
		elif arr2[i] > arr1[i]:
			if not op_arr[i][1]:
				ok = False
				break
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mp = {}
	for i in range(n):
		if a[i] in mp:
			mp[a[i]] += 1
		else:
			mp[a[i]] = 1
	possible = True
	for i in range(n - 1, -1, -1):
		if mp[a[i]] == 1:
			del mp[a[i]]
		else:
			mp[a[i]] -= 1
		if a[i] < b[i] and 1 not in mp:
			possible = False
			break
		elif a[i] > b[i] and -1 not in mp:
			possible = False
			break
	if possible:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
D = defaultdict(lambda : -1)
t = int(input())
d = 0
for k in range(t):
	D = defaultdict(lambda : -1)
	imposs = 0
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n - 1):
		if D[a[i]] == -1:
			D[a[i]] = i
	for i in range(n - 1, 0, -1):
		if b[i] > a[i]:
			if D[1] == -1 or D[1] >= i:
				imposs = 1
				break
		if b[i] < a[i]:
			if D[-1] == -1 or D[-1] >= i:
				imposs = 1
				break
	if a[0] != b[0]:
		imposs = 1
	if imposs == 1:
		print('NO')
	else:
		print('YES')


def decide():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = False
	neg = False
	if a[0] != b[0]:
		return 'NO'
	for i in range(0, n - 1):
		if a[i] == -1:
			neg = True
		if a[i] == 1:
			pos = True
		if b[i + 1] != a[i + 1]:
			if b[i + 1] > a[i + 1] and pos == True:
				continue
			elif b[i + 1] < a[i + 1] and neg == True:
				continue
			else:
				return 'NO'
	return 'YES'
T = int(input())
for i in range(T):
	print(decide())


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	if -1 not in a and max([a[i] - b[i] for i in range(n)]) >= 1:
		print('NO')
		continue
	if 1 not in a and max([b[i] - a[i] for i in range(n)]) >= 1:
		print('NO')
		continue
	if -1 in a:
		neg = a.index(-1)
		if max([a[i] - b[i] for i in range(neg + 1)]) >= 1:
			print('NO')
			continue
	if 1 in a:
		pos = a.index(1)
		if max([b[i] - a[i] for i in range(pos + 1)]) >= 1:
			print('NO')
			continue
	print('YES')


n = int(input())
for i in range(n):
	flag = True
	z = int(input())
	f = list(map(int, input().split()))
	s = list(map(int, input().split()))
	if f[0] != s[0]:
		print('NO')
		flag = False
	un = [f[0], s[0]]
	for i in range(1, z):
		un.append(f[i - 1])
		if not flag:
			break
		if f[i] == s[i]:
			continue
		elif s[i] > f[i] and 1 not in un:
			print('NO')
			flag = False
		elif s[i] < f[i] and -1 not in un:
			print('NO')
			flag = False
	if flag:
		print('YES')


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


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A, B):
	canIncrease = [False]
	canDecrease = [False]
	for (i, x) in enumerate(A):
		canIncrease.append(canIncrease[-1] or x == 1)
		canDecrease.append(canDecrease[-1] or x == -1)
	for i in range(N - 1, -1, -1):
		a = A[i]
		b = B[i]
		if a > b and (not canDecrease[i]):
			return 'NO'
		if a < b and (not canIncrease[i]):
			return 'NO'
	return 'YES'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	ans = solve(N, A, B)
	print(ans)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		result = False
		nums = list()
		if a[0] == b[0]:
			for x in range(len(a)):
				if a[x] == b[x]:
					result = True
				elif a[x] < b[x] and 1 in nums:
					result = True
				elif a[x] > b[x] and -1 in nums:
					result = True
				else:
					result = False
					break
				if a[x] not in nums:
					nums.append(a[x])
		print('YES' if result else 'NO')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	(m, p) = (-1, -1)
	(minus, plus) = (-1, -1)
	for i in range(n):
		if a[i] == -1 and m == -1:
			minus = i
			m = 1
		elif a[i] == 1 and p == -1:
			plus = i
			p = 1
		if p == 1 and m == 1:
			break
	for i in range(n - 1, -1, -1):
		if i == 0 and a[i] != b[i]:
			flag = 1
			break
		if a[i] != b[i]:
			x = b[i] - a[i]
			if x < 0:
				if minus >= i or minus == -1:
					flag = 1
					break
			elif plus >= i or plus == -1:
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')


def method():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	v1 = False
	v2 = False
	flag = 0
	for i in range(n):
		if a[i] < b[i] and v1 == False:
			print('NO')
			return
		elif a[i] > b[i] and v2 == False:
			print('NO')
			return
		elif a[i] == 1:
			v1 = True
		elif a[i] == -1:
			v2 = True
	print('YES')
for _ in range(int(input())):
	method()


t = int(input())
Ans = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mp = set()
	AN = 0
	i = 0
	if a[0] != b[0]:
		Ans.append('NO')
		continue
	else:
		while AN == 0 and i < len(a) - 1:
			mp.add(a[i])
			if b[i + 1] == a[i + 1] or (b[i + 1] > a[i + 1] and 1 in mp) or (b[i + 1] < a[i + 1] and -1 in mp):
				i += 1
				continue
			else:
				AN = 1
	if AN == 0:
		Ans.append('YES')
	else:
		Ans.append('NO')
for i in Ans:
	print(i)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

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

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

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())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

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

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	n = N()
	a = lis()
	b = lis()
	s = set()
	if a[0] != b[0]:
		NO()
		return
	s.add(a[0])
	for i in range(1, n):
		d = b[i] - a[i]
		if d > 0 and 1 not in s:
			NO()
			return
		if d < 0 and -1 not in s:
			NO()
			return
		s.add(a[i])
	YES()
testcase(int(inp()))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c_1 = -1
	c1 = -1
	f = 1
	for i in range(n):
		d = b[i] - a[i]
		if d > 0 and c1 == -1:
			f = 0
			break
		elif d < 0 and c_1 == -1:
			f = 0
			break
		if a[i] == 1:
			c1 = 1
		elif a[i] == -1:
			c_1 = 1
		if c1 == 1 and c_1 == 1:
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


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()]
	c = [-1] * n
	d = [1] * n
	for i in range(1, n):
		c[i] = max(c[i - 1], a[i - 1])
		d[i] = min(d[i - 1], a[i - 1])
	c[0] = 0
	d[0] = 0
	j = n - 1
	equal = True
	for j in range(n - 1, -1, -1):
		if a[j] < b[j] and c[j] <= 0:
			equal = False
			break
		elif a[j] > b[j] and d[j] >= 0:
			equal = False
			break
	if equal:
		print('YES')
	else:
		print('NO')


t = int(input())
for loop in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dic = {}
	dic[0] = 0
	dic[1] = 0
	dic[-1] = 0
	for i in a:
		dic[i] += 1
	flag = True
	for i in range(n - 1, -1, -1):
		dic[a[i]] -= 1
		if a[i] < b[i] and dic[1] == 0:
			flag = False
			break
		elif a[i] > b[i] and dic[-1] == 0:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d1 = False
	d2 = False
	ans = True
	for j in range(n):
		if a[j] > b[j]:
			if not d1:
				ans = False
		if a[j] < b[j]:
			if not d2:
				ans = False
		if a[j] == -1:
			d1 = True
		elif a[j] == 1:
			d2 = True
	if ans:
		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()))
	till_now = []
	f = 0
	for i in range(n):
		if i == 0:
			if a[i] != b[i]:
				print('NO')
				f = 1
				break
			else:
				till_now.append(a[i])
		elif a[i] == b[i]:
			if a[i] not in till_now:
				till_now.append(a[i])
		elif (b[i] - a[i]) / abs(b[i] - a[i]) not in till_now:
			print('NO')
			f = 1
			break
		elif a[i] not in till_now:
			till_now.append(a[i])
	if f == 0:
		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()]
	(hasm, hasp) = (False, False)
	ans = True
	for i in range(n):
		if b[i] < a[i] and (not hasm) or (b[i] > a[i] and (not hasp)):
			ans = False
			break
		if a[i] == -1:
			hasm = True
		if a[i] == 1:
			hasp = True
	print('YES' if ans else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if -1 in a:
		lower = a.index(-1)
	else:
		lower = n + 1
	if 1 in a:
		higher = a.index(1)
	else:
		higher = n + 1
	for (i, (x, y)) in enumerate(zip(a, b)):
		if i == 0 and x != y:
			print('NO')
			break
		if y < x and i <= lower:
			print('NO')
			break
		if y > x and i <= higher:
			print('NO')
			break
	else:
		print('YES')


k = int(input().strip())
for _ in range(k):
	n = int(input().strip())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	if a[0] != b[0]:
		print('NO')
		continue
	for i in range(1, n):
		for j in range(i):
			if b[i] == a[i] or a[j] + a[i] == b[i]:
				break
			if a[j] != 0:
				if a[j] == -1 and a[i] == -1 and (b[i] <= -2) or (a[j] == -1 and a[i] == 1 and (b[i] <= 0)) or (a[j] == -1 and a[i] == 0 and (b[i] <= -1)) or (a[j] == 1 and a[i] == 0 and (b[i] >= 1)) or (a[j] == 1 and a[i] == 1 and (b[i] >= 2)) or (a[j] == 1 and a[i] == -1 and (b[i] >= 0)):
					break
		else:
			print('NO')
			break
	else:
		print('YES')


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	one = False
	minus = False
	res = True
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] < b[i]:
			res = res and one
		else:
			res = res and minus
		one = one or a[i] == 1
		minus = minus or a[i] == -1
	print('YNEOS'[not res::2])


iloZ = int(input())
for i in range(iloZ):
	iloL = int(input())
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	minDod = iloL + 1
	minUje = iloL + 1
	for i in range(iloL):
		if a[i] == 1:
			minDod = i
			break
	for i in range(iloL):
		if a[i] == -1:
			minUje = i
			break
	no = False
	for j in range(iloL - 1, -1, -1):
		if b[j] < a[j]:
			if j <= minUje:
				print('NO')
				no = True
				break
		elif b[j] > a[j]:
			if j <= minDod:
				print('NO')
				no = True
				break
	if no == False:
		print('YES')


queries = int(input())
for _ in range(queries):
	_ = input()
	a = [int(item) for item in input().split()]
	b = [int(item) for item in input().split()]
	p_n = [False, False]
	possible = True
	result = True
	for i in range(len(a)):
		if a[i] > b[i] and (not p_n[1]):
			possible = False
		elif a[i] < b[i] and (not p_n[0]):
			possible = False
		if a[i] == -1:
			p_n[1] = True
		if a[i] == 1:
			p_n[0] = True
	if possible:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	t = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = 0
	q = [0] * 2
	if a[0] == b[0]:
		res = 1
		if a[0] == -1:
			q[0] = -1
		elif a[0] == 1:
			q[1] = 1
		for j in range(1, t):
			c = 0
			if b[j] > a[j] and q[1] == 1:
				c = 1
			elif b[j] < a[j] and q[0] == -1:
				c = 1
			elif b[j] == a[j]:
				c = 1
			res *= c
			if a[j] == -1:
				q[0] = -1
			elif a[j] == 1:
				q[1] = 1
	if res == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	is1 = is_1 = -1
	b = True
	is1 = is_1 = -1
	for i in range(n):
		if brr[i] > arr[i] and is1 == -1:
			b = False
			break
		elif brr[i] < arr[i] and is_1 == -1:
			b = False
			break
		elif arr[i] == 1:
			is1 = 1
		elif arr[i] == -1:
			is_1 = 1
	if b:
		print('YES')
	else:
		print('NO')


for ii in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = [False for i in range(n)]
	first1 = 0
	i = 0
	while i < n:
		if a[i] != 1:
			i += 1
		else:
			break
	first1 = i
	first_1 = 0
	j = 0
	while j < n:
		if a[j] != -1:
			j += 1
		else:
			break
	first_1 = j
	first1 = i
	for i in range(n):
		if a[i] == b[i]:
			ans[i] = True
		elif a[i] > b[i] and i > first_1:
			ans[i] = True
		elif a[i] < b[i] and i > first1:
			ans[i] = True
	if False in ans:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = dict()
	if b[0] != a[0]:
		print('NO')
		continue
	ok = True
	p = 1
	hasone = False
	hasnegative = False
	for i in range(0, n):
		if b[i] < a[i] and (not hasnegative):
			ok = False
		if b[i] > a[i] and (not hasone):
			ok = False
		if a[i] == 1:
			hasone = True
		if a[i] == -1:
			hasnegative = True
	if ok:
		print('YES')
	elif not ok:
		print('NO')


t = int(input())
for o in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = [0] * 3
	f = 0
	for i in range(n):
		if a[i] < b[i]:
			if x[1] > 0:
				f += 1
		elif a[i] > b[i]:
			if x[2] > 0:
				f += 1
		else:
			f += 1
		x[a[i]] += 1
	if f == n:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

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

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	n = int(inp())
	a = lmp()
	b = lmp()
	pos = []
	neg = []
	t = True
	(c1, c2) = (0, 0)
	for i in range(n):
		pos.append(c1)
		neg.append(c2)
		if a[i] == 1:
			c1 += 1
		if a[i] == -1:
			c2 += 1
	for i in range(n - 1, -1, -1):
		if b[i] > a[i]:
			if pos[i] == 0:
				t = False
				break
		if b[i] < a[i]:
			if neg[i] == 0:
				t = False
				break
	print('YES' if t else 'NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(map(int, input().split()))
	t = set()
	for i in range(0, len(s)):
		if s[i] > l[i] and 1 not in t or (s[i] < l[i] and -1 not in t):
			print('NO')
			break
		t.add(l[i])
	else:
		print('YES')


list_ans = []
for _ in range(int(input())):
	pos = 0
	neg = 0
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	for i in range(n):
		if list1[i] < list2[i] and pos == 0:
			list_ans.append('NO')
			break
		if list1[i] > list2[i] and neg == 0:
			list_ans.append('NO')
			break
		if list1[i] == 1:
			pos = 1
		if list1[i] == -1:
			neg = 1
		if pos == 1 and neg == 1:
			list_ans.append('YES')
			break
	else:
		list_ans.append('YES')
for item in list_ans:
	print(item)


t = int(input())
for x in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	v = [999999999999999] * 3
	deff = 0
	v0 = 0
	v2 = 0
	v1 = 0
	for i in range(n):
		if a[i] == -1:
			if v0 == 0:
				v[0] = i
				v0 = 1
		elif a[i] == 0:
			if v1 == 0:
				v[1] = i
				v1 = 1
		elif a[i] == 1:
			if v2 == 0:
				v[2] = i
				v2 = 1
	for i in range(1, n + 1):
		if a[-i] - b[-i] > 0:
			if v[0] < n - i:
				pass
			elif deff == 0:
				print('NO')
				deff = 1
		if a[-i] - b[-i] < 0:
			if v[2] < n - i:
				pass
			elif deff == 0:
				print('NO')
				deff = 1
	if deff == 0:
		print('YES')


for inh in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
	else:
		s = {0, a[0]}
		i = 1
		ans = True
		while i < n and len(s) != 3:
			if a[i] == b[i]:
				s.add(a[i])
			elif a[i] < b[i]:
				if 1 not in s:
					ans = False
					break
				s.add(a[i])
			else:
				if -1 not in s:
					ans = False
					break
				s.add(a[i])
			i += 1
		if ans:
			print('YES')
		else:
			print('NO')


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


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	ct1 = 0
	ct_1 = 0
	f = 0
	for i in range(n):
		if a[i] != b[i]:
			if a[i] - b[i] < 0:
				if ct1 != 1:
					f = 1
					break
			elif ct_1 != 1:
				f = 1
				break
		if a[i] == 1:
			ct1 = 1
		if a[i] == -1:
			ct_1 = 1
	if f == 1:
		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()))
	(p, m) = (0, 0)
	r = 0
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] > b[i]:
			if m == 0:
				r = 1
				break
		elif p == 0:
			r = 1
			break
		if a[i] == 1:
			p = 1
		elif a[i] == -1:
			m = 1
	if r:
		print('NO')
	else:
		print('YES')


import sys
input = lambda : sys.stdin.readline().rstrip()

def I():
	return [int(iI) for iI in input().split()]
(t,) = I()
for _ in range(t):
	(n,) = I()
	a = I()
	b = I()
	st = {a[0]}
	flag = 0
	if a[0] == b[0]:
		for i in range(n):
			if a[i] == b[i]:
				st.add(a[i])
				continue
			elif a[i] < b[i]:
				if 1 not in st:
					flag = 1
			elif -1 not in st:
				flag = 1
			if flag == 1:
				break
			st.add(a[i])
	else:
		flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	was = [False] * 3
	if a[0] != b[0]:
		print('NO')
		continue
	was[a[0] + 1] = True
	ans = 'YES'
	for i in range(1, n):
		if b[i] > a[i] and (not was[2]):
			ans = 'NO'
		if b[i] < a[i] and (not was[0]):
			ans = 'NO'
		was[a[i] + 1] = True
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	i = 0
	var1 = 0
	var2 = 0
	cause = 0
	while i < n:
		if a[i] != b[i]:
			if a[i] < b[i]:
				if var1 == 0:
					cause = 1
					break
			if a[i] > b[i]:
				if var2 == 0:
					cause = 1
					break
		if a[i] > 0:
			var1 = 1
		if a[i] < 0:
			var2 = 1
		i += 1
	if cause == 1:
		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()))
	n = 0
	p = 0
	flag = False
	for i in range(N):
		if a[i] > 0:
			p += 1
		elif a[i] < 0:
			n += 1
	for i in range(N - 1, -1, -1):
		if a[i] > 0:
			p -= 1
		elif a[i] < 0:
			n -= 1
		if a[i] == b[i]:
			continue
		if b[i] > a[i] and p <= 0:
			flag = True
			break
		if b[i] < a[i] and n <= 0:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		(negNum, posNum) = (n, n)
		greenLight = 1
		for i in range(n):
			if negNum == n and a[i] == -1:
				negNum = i
			elif posNum == n and a[i] == 1:
				posNum = i
		for i in range(n - 1, -1, -1):
			if b[i] > a[i]:
				if posNum >= i:
					greenLight = 0
			elif b[i] < a[i]:
				if negNum >= i:
					greenLight = 0
		if greenLight == 0:
			print('NO')
		else:
			print('YES')
main()


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

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

def main():
	T = iin()
	for _ in range(T):
		n = iin()
		a = lin()
		b = lin()
		chk = [0] * 3
		idx = {-1: 0, 1: 2, 0: 1}
		for i in range(n):
			chk[idx[a[i]]] += 1
		for i in range(n - 1, -1, -1):
			chk[idx[a[i]]] -= 1
			if a[i] == b[i]:
				continue
			elif a[i] < b[i]:
				if chk[2]:
					continue
				else:
					print('NO')
					break
			elif chk[0]:
				continue
			else:
				print('NO')
				break
		else:
			print('YES')
main()


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


from collections import Counter

def solve(a, b):
	n = len(a)
	counts = Counter(a)
	for i in range(n - 1, -1, -1):
		itema = a[i]
		itemb = b[i]
		counts[itema] -= 1
		if itema == itemb:
			continue
		elif itema > itemb:
			if counts[-1] == 0:
				return False
		elif counts[1] == 0:
			return False
	return True
for i in range(int(input())):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = solve(a, b)
	print('YES' if res else 'NO')


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()]
	neg1 = False
	pos1 = False
	flag = True
	for i in range(n):
		if a[i] < b[i] and (not pos1):
			flag = False
			break
		if a[i] > b[i] and (not neg1):
			flag = False
			break
		if a[i] == 1:
			pos1 = True
		if a[i] == -1:
			neg1 = True
	if flag:
		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()))
	zc = 0
	nc = 0
	pc = 0
	for i in a:
		if i == 0:
			zc += 1
		elif i == 1:
			pc += 1
		elif i == -1:
			nc += 1
	np = False
	for i in range(n - 1, -1, -1):
		if a[i] == 0:
			zc -= 1
		elif a[i] == 1:
			pc -= 1
		elif a[i] == -1:
			nc -= 1
		if a[i] == b[i]:
			continue
		elif a[i] > b[i]:
			if nc > 0:
				continue
			else:
				np = True
		elif pc > 0:
			continue
		else:
			np = True
	if np:
		print('NO')
	else:
		print('YES')


t = int(input())
for j in range(t):
	n = int(input())
	mass = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	d = dict()
	d[-1] = 0
	d[0] = 0
	d[1] = 0
	f = True
	for i in range(n):
		d[mass[i]] += 1
	for i in range(n - 1, -1, -1):
		d[mass[i]] -= 1
		if mass[i] > arr[i]:
			if d[-1] == 0:
				f = False
				break
		elif mass[i] < arr[i]:
			if d[1] == 0:
				f = False
				break
	if f:
		print('YES')
	else:
		print('NO')


import sys

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

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

def sol():
	n = int(input())
	a = get_ls()
	b = get_ls()
	(x, y) = (0, 0)
	for i in range(n):
		if a[i] > b[i] and (not x):
			print('NO')
			return
		elif a[i] < b[i] and (not y):
			print('NO')
			return
		if a[i] == -1:
			x = 1
		if a[i] == 1:
			y = 1
	print('YES')

def main():
	for _ in range(int(input())):
		sol()
main()


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:n]
	element = set()
	flag = 0
	for i in range(n):
		if a[i] == b[i]:
			element.add(a[i])
			continue
		if a[i] > b[i]:
			if -1 in element:
				element.add(a[i])
				continue
			else:
				flag = 1
				break
		if a[i] < b[i]:
			if 1 in element:
				element.add(a[i])
				continue
			else:
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')


def solve(a, b):
	minus = False
	plus = False
	pos = True
	for i in range(len(a)):
		if b[i] > a[i] and plus == False:
			pos = False
			break
		elif b[i] < a[i] and minus == False:
			pos = False
			break
		if a[i] == 1:
			plus = True
		elif a[i] == -1:
			minus = True
	if pos:
		print('YES')
	else:
		print('NO')

def main():
	nr = int(input())
	for _ in range(nr):
		_ = input()
		a = [int(s) for s in input().split(' ')]
		b = [int(s) for s in input().split(' ')]
		solve(a, b)
main()


for ___ in [0] * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = y = -1
	for i in range(n):
		if a[i] == -1 and x == -1:
			x = i
		if a[i] == 1 and y == -1:
			y = i
	suc = True
	for i in range(n):
		if b[i] < a[i] and (x == -1 or x >= i):
			suc = False
		if b[i] > a[i] and (y == -1 or y >= i):
			suc = False
	print('YES' if suc == True else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a == b:
		print('YES')
		continue
	pos = False
	neg = False
	for (av, bv) in zip(a, b):
		if bv > av:
			if not pos:
				print('NO')
				break
		elif bv < av:
			if not neg:
				print('NO')
				break
		if av > 0:
			pos = True
		elif av < 0:
			neg = True
		if pos and neg:
			print('YES')
			break
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	(ones, minus, zero) = (-1, -1, -1)
	i = 0
	if a[i] == -1:
		minus = i
	if a[i] == 1:
		ones = i
	if a[i] == 0:
		zero = i
	if a[0] != b[0]:
		print('NO')
	else:
		flag = 'YES'
		hh = -1
		for i in range(1, n):
			if b[i] > a[i]:
				if ones != -1 and ones < i:
					hh = 1
				else:
					flag = 'NO'
					break
			if b[i] < a[i]:
				if minus != -1 and minus < i:
					hh = 0
				else:
					flag = 'NO'
					break
			if a[i] == -1:
				minus = i
			if a[i] == 1:
				ones = i
		print(flag)


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	pc = 0
	nc = 0
	ff = 1
	for i in range(n):
		if b[i] - a[i] > 0:
			if not pc:
				ff = 0
		elif a[i] - b[i] > 0:
			if not nc:
				ff = 0
		if a[i] == 1:
			pc += 1
		elif a[i] == -1:
			nc += 1
	if ff:
		print('YES')
	else:
		print('NO')


def increase_count(elem, count):
	if elem > 0:
		count[0] += 1
	elif elem < 0:
		count[1] += 1

def main():
	t = int(input())
	for __ in range(t):
		n = int(input())
		count = [0, 0]
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[0] != b[0]:
			print('NO')
		else:
			flag = True
			increase_count(a[0], count)
			for i in range(1, n):
				if a[i] != b[i]:
					if b[i] > 0 and count[0] == 0:
						flag = False
						break
					elif b[i] < 0 and count[1] == 0:
						flag = False
						break
					elif b[i] == 0:
						if count[0] == 0 and a[i] < 0 or (count[1] == 0 and a[i] > 0):
							flag = False
							break
				increase_count(a[i], count)
			if flag:
				print('YES')
			else:
				print('NO')
main()


for p in range(int(input())):
	(z, h) = (int(input()), 0)
	f = list(map(int, input().split()))
	s = list(map(int, input().split()))
	if f[0] != s[0]:
		print('NO')
		h = 1
	else:
		l = [0, 0, 0]
		for (j, i) in enumerate(s):
			if l[0] and (not l[2]):
				if i <= f[j]:
					pass
				else:
					h = 1
					print('NO')
					break
			elif not l[0] and l[2]:
				if i >= f[j]:
					pass
				else:
					h = 1
					print('NO')
					break
			elif l[0] and l[2]:
				h = 0
				break
			elif i == f[j]:
				pass
			else:
				h = 1
				print('NO')
				break
			if -1 == f[j]:
				l[0] = 1
			if 0 == f[j]:
				l[1] = 1
			if 1 == f[j]:
				l[2] = 1
		if not h:
			print('YES')


(f1, f2, f3) = (False, False, False)

def mark(val):
	global f1, f2, f3
	if val == -1:
		f1 = True
	elif val == 0:
		f2 = True
	else:
		f3 = True
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(f1, f2, f3) = (False, False, False)
	res = 'YES'
	if a[0] != b[0]:
		res = 'NO'
	else:
		mark(a[0])
		for i in range(1, n):
			if b[i] > a[i]:
				if not f3:
					res = 'NO'
					break
			elif b[i] < a[i]:
				if not f1:
					res = 'NO'
					break
			mark(a[i])
	print(res)


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	n = I()
	A = Neo()
	B = Neo()
	(one, negone) = (0, 0)
	f = 0
	for i in range(n):
		if B[i] < A[i] and negone == 0:
			f = 1
			break
		elif B[i] > A[i] and one == 0:
			f = 1
			break
		if A[i] == 1:
			one = 1
		if A[i] == -1:
			negone = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	f1 = 0
	f2 = 0
	n = int(input())
	a = list(mapi())
	b = list(mapi())
	found = 0
	if a[0] == 1:
		f1 = 1
	elif a[0] == -1:
		f2 = 1
	if a[0] != b[0]:
		print('NO')
		continue
	for i in range(1, n):
		if a[i] < b[i] and (not f1) or (a[i] > b[i] and (not f2)):
			found = 1
			break
		if a[i] == 1:
			f1 = 1
		elif a[i] == -1:
			f2 = 1
	if found:
		print('NO')
	else:
		print('YES')


import bisect
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	ans = True
	num_list = [[], [], []]
	for i in range(n):
		num_list[a[i] + 1].append(i)
	for i in range(n - 1, -1, -1):
		val = b[i] - a[i]
		if val == 0:
			continue
		if bisect.bisect_left(num_list[val // abs(val) + 1], i) > 0:
			continue
		else:
			ans = False
	if ans:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
	else:
		arr = [0] * 3
		arr[1 + a[0]] = 1
		for i in range(1, n):
			if a[i] > b[i] and arr[0] == 0:
				print('NO')
				break
			if a[i] < b[i] and arr[2] == 0:
				print('NO')
				break
			arr[1 + a[i]] += 1
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	st = set()
	ans = 1
	flag = False
	for i in range(n):
		if a[i] != b[i]:
			dif = b[i] - a[i]
			if dif > 0:
				if 1 not in st:
					flag = True
					ans = 0
					break
			elif -1 not in st:
				flag = True
				ans = 0
				break
			st.add(a[i])
		else:
			st.add(a[i])
	if ans:
		print('YES')
	else:
		print('NO')


test_cases = int(input())

def testCase():
	n = int(input())
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	return_string = 'YES'
	curr_a = set()
	for i in range(n):
		if a[i] < b[i]:
			if 1 not in curr_a:
				return_string = 'NO'
				break
		elif a[i] > b[i]:
			if -1 not in curr_a:
				return_string = 'NO'
				break
		curr_a.add(a[i])
	print(return_string)
for t in range(test_cases):
	testCase()


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


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	Dict = defaultdict(bool)
	flag = False
	for i in range(n):
		if a[i] == b[i]:
			Dict[a[i]] = True
			continue
		elif a[i] > b[i]:
			if Dict[-1] == True:
				Dict[a[i]] = True
				continue
			else:
				print('NO')
				flag = True
				break
		elif a[i] < b[i]:
			if Dict[1] == True:
				Dict[a[i]] = True
				continue
			else:
				print('NO')
				flag = True
				break
	if flag == False:
		print('YES')


import sys
t = int(input())
inp = [line.strip().split() for line in reversed(sys.stdin.readlines())]
ans = []
while t:
	n = int(inp.pop()[0])
	a = [int(i) for i in inp.pop()]
	b = [int(i) for i in inp.pop()]
	dpp = [False]
	dpm = [False]
	for ai in a:
		if dpp[-1] or ai == 1:
			dpp.append(True)
		else:
			dpp.append(False)
		if dpm[-1] or ai == -1:
			dpm.append(True)
		else:
			dpm.append(False)
	flag = True
	for i in range(n):
		if b[i] > a[i] and (not dpp[i]) or (b[i] < a[i] and (not dpm[i])):
			flag = False
			break
	if flag:
		ans.append('YES')
	else:
		ans.append('NO')
	t -= 1
print(*ans, sep='\n')


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	r = []
	for i in range(n):
		if i == 0:
			if a[0] != b[0]:
				f = 1
				break
			else:
				r.append(a[i])
		elif a[i] == b[i]:
			r.append(a[i])
		elif a[i] < 0:
			if b[i] > a[i]:
				if 1 in r:
					r.append(a[i])
				else:
					f = 1
					break
			elif -1 in r:
				r.append(a[i])
			else:
				f = 1
				break
		elif a[i] == 0:
			if b[i] < 0:
				if -1 in r:
					r.append(a[i])
				else:
					f = 1
					break
			if b[i] > 0:
				if 1 in r:
					r.append(a[i])
				else:
					f = 1
					break
		elif b[i] > a[i]:
			if 1 in r:
				r.append(a[i])
			else:
				f = 1
				break
		elif -1 in r:
			r.append(a[i])
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	x = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dp = list()
	if a[0] != b[0]:
		print('NO')
	else:
		flag = 0
		dp.append(a[0])
		for i in range(1, x):
			if a[i] != b[i]:
				if b[i] > 0:
					if 1 in dp:
						pass
					else:
						print('NO')
						flag = 1
						break
				elif b[i] < 0:
					if -1 in dp:
						pass
					else:
						print('NO')
						flag = 1
						break
				elif b[i] == 0:
					if a[i] < 0:
						if 1 in dp:
							pass
						else:
							flag = 1
							print('NO')
							break
					elif -1 in dp:
						pass
					else:
						flag = 1
						print('NO')
						break
			dp.append(a[i])
		if flag == 0:
			print('YES')


t = int(input())
while t > 0:
	n1 = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	p = 0
	z = 0
	n = 0
	for i in range(n1):
		if a[i] == 1:
			p += 1
		elif a[i] == 0:
			z += 1
		else:
			n += 1
	flag = 0
	for i in range(n1 - 1, 0, -1):
		if a[i] == 1:
			p -= 1
		elif a[i] == 0:
			z -= 1
		else:
			n -= 1
		if b[i] > a[i]:
			if p < 1:
				flag = 1
				break
		elif b[i] < a[i]:
			if n < 1:
				flag = 1
				break
	if a[0] != b[0]:
		flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'YES'
	dic = {1: 100001, -1: 100001}
	for i in range(n):
		if a[i] == 1 and dic[1] == 100001:
			dic[1] = i
		elif a[i] == -1 and dic[-1] == 100001:
			dic[-1] = i
		if dic[1] != 100001 and dic[-1] != 100001:
			break
	for i in range(n):
		if a[i] < b[i] and dic[1] >= i or (a[i] > b[i] and dic[-1] >= i):
			ans = 'NO'
			break
	print(ans)


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


for i in range(int(input())):
	n = int(input())
	l1 = [int(j) for j in input().split()][:n]
	l2 = [int(j) for j in input().split()][:n]
	c = 0
	if l1 == l2:
		print('YES')
	elif l1[0] != l2[0]:
		print('NO')
	else:
		a = n
		b = n
		try:
			a = l1.index(1)
		except:
			pass
		try:
			b = l1.index(-1)
		except:
			pass
		for j in range(n - 1, 0, -1):
			if l1[j] < l2[j] and a >= j:
				c = -1
				break
			elif l1[j] > l2[j] and b >= j:
				c = -1
				break
		if c == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	la = list(map(int, input().split()))
	lb = list(map(int, input().split()))
	leastIdx = [None, None, None]
	for i in range(n):
		if leastIdx[la[i]] is None:
			leastIdx[la[i]] = i
	f = True
	for i in range(n):
		if lb[i] > la[i]:
			if leastIdx[1] is None or leastIdx[1] >= i:
				f = False
				break
		elif lb[i] < la[i]:
			if leastIdx[-1] is None or leastIdx[-1] >= i:
				f = False
				break
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = input()
	a = input()
	b = input()
	a = [int(i) for i in a.split()]
	b = [int(i) for i in b.split()]
	true = {}
	for j in range(len(a)):
		if a[j] == -1:
			if -1 not in true:
				true[-1] = j
		elif a[j] == 1:
			if 1 not in true:
				true[1] = j
		if -1 in true and 1 in true:
			break
	flag = True
	for k in range(len(b)):
		if b[k] - a[k] > 0:
			if 1 not in true or true[1] >= k:
				print('NO')
				flag = False
				break
		elif b[k] - a[k] < 0:
			if -1 not in true or true[-1] >= k:
				print('NO')
				flag = False
				break
	if flag:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count1 = 0
	count2 = 0
	flag = 0
	for i in range(n):
		if b[i] < a[i] and count2 == 0:
			flag = 1
			break
		elif b[i] > a[i] and count1 == 0:
			flag = 1
			break
		if a[i] == -1:
			count2 += 1
		elif a[i] == 1:
			count1 += 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


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()))
	if a[0] != b[0]:
		print('NO')
		continue
	C = [set() for _ in range(n)]
	S = set()
	for i in range(n):
		val = a[i]
		S.add(val)
		C[i] |= S
	for i in range(n - 1, 0, -1):
		if a[i] > b[i] and (not -1 in C[i - 1]):
			print('NO')
			break
		if b[i] > a[i] and (not 1 in C[i - 1]):
			print('NO')
			break
	else:
		print('YES')


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()]
	(present, ok) = (set(), True)
	for i in range(len(a)):
		if a[i] == b[i] and a[i] == 1:
			present.add(1)
		if a[i] == b[i] and a[i] == -1:
			present.add(-1)
		if a[i] != b[i]:
			if len(present) > 0:
				if b[i] < a[i]:
					if -1 not in present:
						ok = False
						break
				if b[i] > a[i]:
					if 1 not in present:
						ok = False
						break
			else:
				ok = False
				break
			present.add(a[i])
	if ok == True:
		print('YES')
	else:
		print('NO')


M = 1000000007
import sys

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

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

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	A = alele()
	B = alele()
	pos = 0
	neg = 0
	flag = 0
	for i in range(n):
		if B[i] > A[i] and pos == 0:
			flag = 1
			break
		elif B[i] < A[i] and neg == 0:
			flag = 1
			break
		if A[i] > 0:
			pos = 1
		elif A[i] < 0:
			neg = 1
	print('YES') if flag == 0 else print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	flag = 1
	for i in range(n):
		if a[i] == b[i]:
			d[a[i]] = 1
			continue
		elif b[i] == 0:
			if a[i] > 0:
				if -1 not in d:
					flag = 0
					break
				else:
					d[a[i]] = 1
			elif 1 not in d:
				flag = 0
				break
			else:
				d[a[i]] = 1
		elif b[i] > 0:
			if 1 not in d:
				flag = 0
				break
			else:
				d[a[i]] = 1
		elif b[i] < 0:
			if -1 not in d:
				flag = 0
				break
			else:
				d[a[i]] = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		b = LI()
		ok = True
		t = [True, False, False]
		for (c, d) in zip(a, b):
			i = 0
			if c < d:
				i = 1
			if c > d:
				i = 2
			if not t[i]:
				ok = False
				break
			t[c] = True
		rr.append(IF(ok, 'YES', 'NO'))
	return JA(rr, '\n')
print(main())


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if n == 1:
		if a[0] == b[0]:
			print('YES')
		else:
			print('NO')
		continue
	dp = [[0, 0, 0] for i in range(n - 1)]
	dp[0][a[0]] += 1
	for i in range(1, n - 1):
		dp[i][a[i]] += 1
		dp[i][0] += dp[i - 1][0]
		dp[i][1] += dp[i - 1][1]
		dp[i][-1] += dp[i - 1][-1]
	done = False
	for i in range(n - 1, -1, -1):
		dif = b[i] - a[i]
		if i == 0:
			if dif != 0:
				done = True
		if dif > 0:
			if dp[i - 1][1] > 0:
				continue
			else:
				done = True
				break
		elif dif < 0:
			if dp[i - 1][-1] > 0:
				continue
			else:
				done = True
				break
	if done:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m, p) = (int(input()), set(), 0)
	(a, b) = (input().split(), input().split())
	for i in range(n):
		if int(b[i]) - int(a[i]) > 0:
			if '1' not in m:
				p = 1
				break
		elif int(b[i]) - int(a[i]) < 0:
			if '-1' not in m:
				p = 1
				break
		m.add(a[i])
	if p == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
T = {-1: 1, 0: 2, 1: 4}

def solution():
	input()
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if A[0] != B[0]:
		print('NO')
		return
	X = 0
	for i in range(1, len(A)):
		X |= T[A[i - 1]]
		a = A[i]
		b = B[i]
		if a == b:
			continue
		if a < b and X & 4 == 0:
			print('NO')
			return
		if a > b and X & 1 == 0:
			print('NO')
			return
	print('YES')
for _ in range(n):
	solution()


t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	next_step = True
	is_1 = False
	is_minus_1 = False
	i = 0
	while next_step and i < n:
		if a[i] > b[i] and (not is_minus_1):
			next_step = False
		elif a[i] < b[i] and (not is_1):
			next_step = False
		if a[i] == -1:
			is_minus_1 = True
		elif a[i] == 1:
			is_1 = True
		i += 1
	if next_step:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	fl1 = 0
	fl2 = 0
	for i in range(n):
		if a[i] == b[i]:
			if a[i] == 1:
				fl1 = 1
			if a[i] == -1:
				fl2 = 1
			continue
		if a[i] < b[i] and fl1:
			if a[i] == 1:
				fl1 = 1
			if a[i] == -1:
				fl2 = 1
			continue
		if a[i] > b[i] and fl2:
			if a[i] == 1:
				fl1 = 1
			if a[i] == -1:
				fl2 = 1
				continue
		else:
			print('NO')
			break
	else:
		print('YES')


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
for _ in range(vary(1)):
	n = vary(1)
	a = array_int()
	b = array_int()
	if a[0] != b[0]:
		print('NO')
		continue
	s = set()
	k = 0
	s.add(a[0])
	for i in range(1, n):
		k = 0
		for j in s:
			if b[i] > a[i] and j > 0:
				k = 1
			if b[i] == a[i]:
				k = 1
			if b[i] < a[i] and j < 0:
				k = 1
		if k != 1:
			print('NO')
			break
		s.add(a[i])
	else:
		print('YES')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	freqs = [0] * 3
	ans = 'YES'
	for i in range(n):
		if all(freqs) > 0:
			break
		if a[i] > b[i]:
			if freqs[-1] == 0:
				ans = 'NO'
				break
		elif a[i] < b[i]:
			if freqs[1] == 0:
				ans = 'NO'
				break
		freqs[a[i]] += 1
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	p1 = p_1 = 100005
	for i in range(n):
		if a[i] == 1:
			p1 = min(p1, i)
		elif a[i] == -1:
			p_1 = min(p_1, i)
	flg = True
	for i in range(n):
		if b[i] < a[i]:
			if p_1 >= i:
				flg = False
				break
		elif b[i] > a[i]:
			if p1 >= i:
				flg = False
				break
	if flg:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ans = 'YES'
	if a[0] != b[0]:
		ans = 'NO'
	p = [2, 2, 2]
	p[a[0]] = 1
	for i in range(1, len(b)):
		if b[i] != a[i]:
			if b[i] > a[i] and p[1] != 1:
				ans = 'NO'
				break
			elif b[i] < a[i] and p[-1] != 1:
				ans = 'NO'
				break
		p[a[i]] = 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arra = list(map(int, input().split()))
	arrb = list(map(int, input().split()))
	minus = 1
	one = 1
	flag = True
	for i in range(n):
		if arrb[i] > arra[i]:
			if one:
				flag = False
				break
			elif arra[i] == -1 and minus:
				minus = 0
				break
		elif arrb[i] < arra[i]:
			if minus:
				flag = False
				break
			elif arra[i] == 1 and one:
				one = 0
				break
		elif arrb[i] == arra[i]:
			if arra[i] == 1 and one:
				one = 0
			elif arra[i] == -1 and minus:
				minus = 0
			if minus == one == 0:
				break
	if flag:
		print('YES')
	else:
		print('NO')


ans = []
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		ans.append('NO')
		continue
	pl = False
	mn = False
	if a[0] == 1:
		pl = True
	elif a[0] == -1:
		mn = True
	ok = False
	for i in range(1, n):
		if a[i] > b[i] and (not mn):
			ok = True
			break
		if a[i] < b[i] and (not pl):
			ok = True
			break
		if a[i] == 1:
			pl = True
		elif a[i] == -1:
			mn = True
	if ok:
		ans.append('NO')
		continue
	ans.append('YES')
print('\n'.join(ans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(z, o, mo) = (1e+18, 1e+18, 1e+18)
	for t in range(n):
		if a[t] == 0 and z == 1e+18:
			z = t
		elif a[t] == 1 and o == 1e+18:
			o = t
		elif a[t] == -1 and mo == 1e+18:
			mo = t
	f = 1
	for t in range(n):
		if b[t] < a[t]:
			if mo >= t:
				f = 0
				break
		elif b[t] > a[t]:
			if o >= t:
				f = 0
				break
	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()))
	if a[0] == b[0]:
		check = [[0, 0] for _ in range(n)]
		for i in range(1, n):
			if a[i - 1] == 1 or check[i - 1][0] == 1:
				check[i][0] = 1
			if a[i - 1] == -1 or check[i - 1][1] == 1:
				check[i][1] = 1
		tf = True
		for i in range(n - 1, 0, -1):
			if b[i] == a[i]:
				pass
			elif b[i] > a[i]:
				if check[i][0] == 1:
					pass
				else:
					tf = False
					break
			elif check[i][1] == 1:
				pass
			else:
				tf = False
				break
		if tf:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = False
	m = False
	f = 0
	for i in range(n):
		if a[i] > b[i] and m == False:
			print('NO')
			f = 1
			break
		elif a[i] < b[i] and p == False:
			print('NO')
			f = 1
			break
		if a[i] > 0:
			p = True
		elif a[i] < 0:
			m = True
	if f == 0:
		print('YES')


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = True
	o = False
	mo = False
	flag = True
	i = 0
	while flag and i < n:
		if a[i] == b[i]:
			pass
		elif a[i] > b[i] and mo:
			pass
		elif a[i] < b[i] and o:
			pass
		else:
			res = False
			flag = False
		if a[i] == 1:
			o = True
		elif a[i] == -1:
			mo = True
		i += 1
	if res:
		print('YES')
	else:
		print('NO')


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


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

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

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

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

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	n = scanner()
	a = get_list()
	b = get_list()
	mp = {}
	for i in range(n):
		if b[i] < 0 and b[i] != a[i] and (mp.get(-1) == None):
			print('NO')
			return
		if b[i] > 0 and b[i] != a[i] and (mp.get(1) == None):
			print('NO')
			return
		if b[i] == 0:
			if a[i] == 1 and mp.get(-1) == None:
				print('NO')
				return
			elif a[i] == -1 and mp.get(1) == None:
				print('NO')
				return
		mp[a[i]] = 1
	print('YES')
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


for t in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	if arr1.count(1) > 0:
		index_one = arr1.index(1)
	else:
		index_one = n + 1
	if arr1.count(-1) > 0:
		index_minus_one = arr1.index(-1)
	else:
		index_minus_one = n + 1
	broken = 0
	for i in range(n - 1, -1, -1):
		ele_a = arr1[i]
		ele_b = arr2[i]
		if ele_a == ele_b:
			continue
		elif ele_a < ele_b:
			if index_one < i:
				continue
			else:
				broken += 1
				break
		elif ele_b < ele_a:
			if index_minus_one < i:
				continue
			else:
				broken += 1
				break
	if broken == 0:
		print('YES')
	else:
		print('NO')


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	temp = list(map(int, sys.stdin.readline().split()))
	zero = [0] * n
	pos = [0] * n
	neg = [0] * n
	for i in range(n):
		if arr[i] > 0:
			pos[i] += 1
		elif arr[i] < 0:
			neg[i] += 1
		else:
			zero[i] += 1
	prefix_zero = [0] * n
	prefix_pos = [0] * n
	prefix_neg = [0] * n
	prefix_zero[0] = zero[0]
	prefix_pos[0] = pos[0]
	prefix_neg[0] = neg[0]
	for i in range(1, n):
		prefix_zero[i] = prefix_zero[i - 1] + zero[i]
		prefix_pos[i] = prefix_pos[i - 1] + pos[i]
		prefix_neg[i] = prefix_neg[i - 1] + neg[i]
	if arr[0] == temp[0]:
		no = False
		for i in range(1, n):
			if temp[i] > 0:
				if temp[i] != arr[i]:
					if prefix_pos[i - 1] == 0:
						no = True
						break
			elif temp[i] < 0:
				if temp[i] != arr[i]:
					if prefix_neg[i - 1] == 0:
						no = True
						break
			elif arr[i] > 0:
				if prefix_neg[i - 1] == 0:
					no = True
					break
			elif arr[i] < 0:
				if prefix_pos[i - 1] == 0:
					no = True
					break
		print('YES' if not no else 'NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	if arr == brr:
		print('YES')
		continue
	if arr[0] != brr[0]:
		print('NO')
		continue
	(a, b, c, p) = (0, 0, 0, 0)
	if arr[0] > 0:
		a = 1
	elif arr[0] < 0:
		b = -1
	for i in range(1, n):
		if brr[i] > arr[i]:
			if a == 1:
				p += 1
		elif brr[i] < arr[i]:
			if b == -1:
				p += 1
		else:
			p += 1
		if arr[i] > 0:
			a = 1
		elif arr[i] < 0:
			b = -1
	if p == n - 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [0]
	h = 0
	for j in range(n):
		p = b[j] - a[j]
		if p > 0:
			if 1 in c:
				pass
			else:
				h = 1
				break
		if p < 0:
			if -1 in c:
				pass
			else:
				h = 1
				break
		if a[j] not in c:
			c.append(a[j])
	if h == 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()))
	s = {0}
	rslt = 1
	for i in range(n):
		if 1 in s and -1 in s:
			break
		elif b[i] > a[i]:
			if 1 not in s:
				rslt = 0
				break
		elif b[i] < a[i]:
			if -1 not in s:
				rslt = 0
				break
		s.add(a[i])
	print(['NO', 'YES'][rslt])


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

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

def mdata():
	return map(int, data().split())
mod = int(1000000000.0 + 7)
for i in range(int(data())):
	(n,) = mdata()
	a = list(mdata())
	b = list(mdata())
	s = set()
	flag = True
	for i in range(n):
		flag = False
		if b[i] == a[i]:
			flag = True
		if b[i] - a[i] > 0:
			if 1 in s:
				flag = True
		elif -1 in s:
			flag = True
		if flag == False:
			break
		s.add(a[i])
	if flag == False:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	cnt = [0] * 3
	ans = 'YES'
	for i in range(n):
		if a[i] > b[i]:
			if cnt[0] == 0:
				ans = 'NO'
				break
		elif a[i] < b[i]:
			if cnt[2] == 0:
				ans = 'NO'
				break
		cnt[a[i] + 1] = 1
	print(ans)
	t -= 1


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = [0, 0]
	s = 0
	for i in range(n):
		if b[i] < a[i] and f[0] != 1 or (b[i] > a[i] and f[1] != 1):
			print('NO')
			s = 1
			break
		if a[i] == -1:
			f[0] = 1
		if a[i] == 1:
			f[1] = 1
	if s == 0:
		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()]
	if a[0] != b[0]:
		print('NO')
		continue
	count_neg = 1 if a[0] == -1 else 0
	count_pos = 1 if a[0] == 1 else 0
	flag = 0
	for j in range(1, n):
		if a[j] == b[j]:
			count_neg += 1 if a[j] == -1 else 0
			count_pos += 1 if a[j] == 1 else 0
			continue
		elif b[j] - a[j] > 0 and count_pos == 0:
			flag = 1
			break
		elif b[j] - a[j] < 0 and count_neg == 0:
			flag = 1
			break
		count_neg += 1 if a[j] == -1 else 0
		count_pos += 1 if a[j] == 1 else 0
	print('NO' if flag else 'YES')


def solve(a, b, n):
	(s, p) = (0, 0)
	for i in range(n):
		if p == 0 and b[i] - a[i] > 0:
			return 'NO'
		if s == 0 and b[i] - a[i] < 0:
			return 'NO'
		if a[i] < 0:
			s = 1
		if a[i] > 0:
			p = 1
	return 'YES'
for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	print(solve(a, b, n))


import sys
from sys import stdin, stdout
import bisect
import math
import heapq
import collections

def modinv(n, p):
	return pow(n, p - 2, p)

def nc():
	return map(int, ns().split())

def narr():
	return list(map(int, ns().split()))

def ns():
	return input()

def ni():
	return int(input())
cases = ni()
for case in range(cases):
	n = ni()
	a = narr()
	b = narr()
	possible = True
	found_neg = False
	found_pos = False
	for i in range(n):
		if a[i] < b[i]:
			if not found_pos:
				possible = False
		elif a[i] > b[i]:
			if not found_neg:
				possible = False
		if a[i] == -1:
			found_neg = True
		elif a[i] == 1:
			found_pos = True
	if possible:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	y = x = -1
	flag = 0
	for i in range(n):
		if l1[i] == 1:
			x = i
			break
	for i in range(n):
		if l1[i] == -1:
			y = i
			break
	for i in range(n):
		if l2[i] < l1[i] and y >= i or (l2[i] < l1[i] and y == -1):
			flag = 1
			break
		if l2[i] > l1[i] and x >= i or (l2[i] > l1[i] and x == -1):
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys

def main():
	t = int(input())
	for _ in range(t):
		n = int(sys.stdin.readline())
		list1 = list(map(int, sys.stdin.readline().split()))
		list2 = list(map(int, sys.stdin.readline().split()))
		list1Dict = {-1: 0, 0: 0, 1: 0}
		flag = True
		for i in range(n):
			if list1[i] == list2[i]:
				pass
			elif list1[i] < list2[i]:
				if list1Dict[1]:
					pass
				else:
					flag = False
					break
			elif list1[i] > list2[i]:
				if list1Dict[-1]:
					pass
				else:
					flag = False
					break
			list1Dict[list1[i]] += 1
		if flag:
			print('YES')
		else:
			print('NO')
	return
main()


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

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	n = int(input())
	(a, b) = (I(), I())
	f = 0
	done = {1: 0, -1: 0, 0: 0}
	for i in range(n):
		if b[i] > a[i] and (not done[1]) or (b[i] < a[i] and (not done[-1])):
			f = 1
			break
		done[a[i]] = 1
	print(['YES', 'NO'][f])


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	(x, y, f) = (0, 0, True)
	for i in range(n):
		if a[i] < b[i] and x == 0:
			f = False
			break
		if a[i] > b[i] and y == 0:
			f = False
			break
		if a[i] == 1:
			x = 1
		if a[i] == -1:
			y = 1
	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()))
	if a[0] != b[0]:
		print('NO')
	else:
		flag = True
		f1 = 0
		f2 = 0
		if a[0] == 1:
			f1 = 1
		elif a[0] == -1:
			f2 = 1
		for i in range(1, n):
			if a[i] > b[i] and f2 == 0 or (a[i] < b[i] and f1 == 0):
				flag = False
				break
			if a[i] == 1:
				f1 = 1
			elif a[i] == -1:
				f2 = 1
		if flag:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	num = [0] * n
	for i in range(n):
		num[i] = [False, False]
	if n == 1:
		print('NO' if a[0] != b[0] else 'YES')
		return
	if a[0] == 1:
		num[1][1] = True
	elif a[0] == -1:
		num[1][0] = True
	for i in range(2, n):
		num[i][0] = num[i - 1][0]
		num[i][1] = num[i - 1][1]
		if a[i - 1] == 1:
			num[i][1] = True
		elif a[i - 1] == -1:
			num[i][0] = True
	for i in range(n - 1, -1, -1):
		if a[i] > b[i] and num[i][0] == False:
			print('NO')
			return
		if a[i] < b[i] and num[i][1] == False:
			print('NO')
			return
	print('YES')

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


import sys, math
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	b = list(map(int, I().split()))
	s = set()
	if n == 1:
		if a[0] == b[0]:
			ans += 'YES\n'
		else:
			ans += 'NO\n'
	elif a[0] != b[0]:
		ans += 'NO\n'
	elif a[0] == 0 and b[1] > a[1]:
		ans += 'NO\n'
	else:
		flag = 1
		for i in range(n - 1):
			s.add(a[i])
			if b[i + 1] > 0:
				if 1 not in s and a[i + 1] != b[i + 1]:
					flag = 0
					break
			elif b[i + 1] < 0:
				if -1 not in s and a[i + 1] != b[i + 1]:
					flag = 0
					break
			elif a[i + 1] != 0:
				if a[i + 1] == 1:
					if -1 not in s:
						flag = 0
						break
				elif 1 not in s:
					flag = 0
					break
		if flag:
			ans += 'YES\n'
		else:
			ans += 'NO\n'
print(ans)


t = int(input())
for k in range(1, t + 1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ase = set(a)
	l = []
	f = 0
	fs = 0
	fn = 0
	for i in range(0, n):
		if a[i] != b[i] and i == 0:
			f = 1
			break
		elif a[i] < b[i]:
			if fs == 0:
				f = 1
				break
		elif a[i] > b[i]:
			if fn == 0:
				f = 1
				break
		if a[i] == 1:
			fs = 1
		if a[i] == -1:
			fn = 1
	if f == 1:
		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()))

	def ans(n, a, b):
		plus = False
		minus = False
		for i in range(n):
			if a[i] < b[i]:
				if not plus:
					return 'NO'
			elif a[i] > b[i]:
				if not minus:
					return 'NO'
			if a[i] == +1:
				plus = True
			if a[i] == -1:
				minus = True
		return 'YES'
	print(ans(n, a, b))


def good(n, a, b):
	temp = [a[0]]
	if a[0] != b[0]:
		return False
	for i in range(1, n):
		if b[i] > a[i]:
			if 1 not in temp:
				return False
		elif b[i] < a[i]:
			if -1 not in temp:
				return False
		if a[i] not in temp:
			temp.append(a[i])
		if len(temp) == 3:
			return True
	return True
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if good(n, a, b):
		print('YES')
	else:
		print('NO')


a = int(input())
for _ in range(a):
	l = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	x1 = 0
	x2 = 0
	f = 1
	if x[0] != y[0]:
		f = 0
	else:
		if x[0] == 1:
			x1 = 1
		if x[0] == -1:
			x2 = 1
		for i in range(1, l):
			if y[i] > x[i] and x1 == 0:
				f = 0
			if y[i] < x[i] and x2 == 0:
				f = 0
			if x[i] == 1:
				x1 = 1
			if x[i] == -1:
				x2 = 1
	if f == 1:
		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()))
	check = [False, False, False]
	result = 'YES'
	if a[0] != b[0]:
		print('NO')
		continue
	if a[0] == 0 or a[0] == 1 or a[0] == -1:
		check[a[0]] = True
	for i in range(1, n):
		if b[i] > a[i] and check[1] == True:
			None
		elif b[i] == a[i]:
			None
		elif b[i] < a[i] and check[-1] == True:
			None
		else:
			result = 'NO'
			break
		if a[i] == 0 or a[i] == 1 or a[i] == -1:
			check[a[i]] = True
	print(result)


from sys import stdin
input = stdin.readline
R = lambda : list(map(int, input().split()))
T = int(input())
for _ in range(T):
	n = int(input())
	(a, b) = (R(), R())
	(p, m, ok) = (0, 0, 1)
	for i in range(n):
		if a[i] < b[i] and (not p):
			ok = 0
		if a[i] > b[i] and (not m):
			ok = 0
		if a[i] > 0:
			p = 1
		if a[i] < 0:
			m = 1
		if not ok:
			break
	print('YES' if ok else 'NO')


def noob():
	return 5 + 10
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = [int(ele) for ele in input().split()]
	b = [int(elem) for elem in input().split()]
	on = [-1] * n
	non = [-1] * n
	pronoob = -1
	for i in range(n):
		on[i] = pronoob
		if a[i] == 1:
			pronoob = i
	pronoob = -1
	for i in range(n):
		non[i] = pronoob
		if a[i] == -1:
			pronoob = i
	flag = 0
	for i in range(n):
		t1 = a[i] - b[i]
		if t1 < 0 and on[i] == -1:
			flag = 1
			break
		if t1 > 0 and non[i] == -1:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
ans = []
for g in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = 0
	m = 0
	f = 1
	if a[0] == 1:
		p = 1
	if a[0] == -1:
		m = 1
	if a[0] != b[0]:
		f = 0
	else:
		for i in range(1, n):
			if not (b[i] > a[i] and p == 1 or (b[i] < a[i] and m == 1) or b[i] == a[i]):
				f = 0
				break
			if a[i] == 1:
				p = 1
			if a[i] == -1:
				m = 1
			if p == m == 1:
				break
	if f == 0:
		ans.append('NO')
	else:
		ans.append('YES')
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	x = 0
	y = 0
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = True
	for j in range(n):
		if a[j] < b[j] and y > 0 or (a[j] > b[j] and x > 0) or a[j] == b[j]:
			flag = True
		else:
			flag = False
			break
		if a[j] == -1:
			x = x + 1
		elif a[j] == 1:
			y = y + 1
	if flag == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	nn = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	done = 0
	if arr1[0] != arr2[0]:
		print('NO')
		done = 1
	else:
		cont = [0, 0, 0]
		for (index, i) in enumerate(arr2):
			if cont[0] and (not cont[2]):
				if i <= arr1[index]:
					pass
				else:
					done = 1
					print('NO')
					break
			elif not cont[0] and cont[2]:
				if i >= arr1[index]:
					pass
				else:
					done = 1
					print('NO')
					break
			elif cont[0] and cont[2]:
				done = 0
				break
			elif i == arr1[index]:
				pass
			else:
				done = 1
				print('NO')
				break
			if -1 == arr1[index]:
				cont[0] = 1
			if 0 == arr1[index]:
				cont[1] = 1
			if 1 == arr1[index]:
				cont[2] = 1
		if not done:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a_neg = 10000000000000000000000000
	a_pos = 10000000000000000000000000
	for i in range(n):
		if a_neg == 10000000000000000000000000:
			if a[i] < 0:
				a_neg = i
		if a_pos == 10000000000000000000000000:
			if a[i] > 0:
				a_pos = i
	k = 1
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(n):
			if a[i] > b[i]:
				if i <= a_neg:
					print('NO')
					k = 0
					break
			if a[i] < b[i]:
				if i <= a_pos:
					print('NO')
					k = 0
					break
		if k == 1:
			print('YES')


def solve(n, a, b):
	(x, y) = (0, 0)
	for i in range(n):
		if x == 0 and y == 0 and (a[i] != b[i]):
			return False
		if x == 1 and y == 1:
			return True
		if x == 1 and a[i] < b[i]:
			return False
		if y == 1 and a[i] > b[i]:
			return False
		if a[i] == -1:
			x = 1
		if a[i] == 1:
			y = 1
	return True

def main():
	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()]
		if solve(n, a, b):
			print('YES')
		else:
			print('NO')
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	plus = False
	minus = False
	for j in range(n):
		if b[j] > a[j] and (not plus) or (b[j] < a[j] and (not minus)):
			print('NO')
			break
		if not minus and a[j] == -1:
			minus = True
		if not plus and a[j] == 1:
			plus = True
	else:
		print('YES')


def check(a, b, n):
	used = set()
	if a[0] != b[0]:
		return 'NO'
	for i in range(n):
		if a[i] == b[i]:
			used.add(a[i])
			continue
		if b[i] > a[i] and 1 in used:
			used.add(a[i])
			continue
		if b[i] < a[i] and -1 in used:
			used.add(a[i])
			continue
		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(check(a, b, n))


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = 100000000
	m = 100000000
	for i in range(n):
		if a[i] == -1:
			m = min(m, i)
		if a[i] == 1:
			p = min(p, i)
	odp = True
	for i in range(n):
		if a[i] < b[i] and p >= i:
			odp = False
			break
		if a[i] > b[i] and m >= i:
			odp = False
			break
	if odp:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	ara = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	flag = True
	for i in range(0, n):
		if ara[i] != brr[i]:
			flag = False
			break
	if flag == True:
		print('YES')
	elif ara[0] != brr[0]:
		print('NO')
	else:
		pos = 0
		neg = 0
		if ara[0] > 0:
			pos = 1
		elif ara[0] < 0:
			neg = 1
		flag = True
		for i in range(1, n):
			if ara[i] != brr[i]:
				if brr[i] == 0:
					if ara[i] == -1 and pos == 0:
						flag = False
						break
					elif ara[i] == 1 and neg == 0:
						flag = False
						break
				elif brr[i] < 0:
					if neg == 0:
						flag = False
						break
					else:
						flag = True
				elif pos == 0:
					flag = False
					break
				else:
					flag = True
			if ara[i] > 0:
				pos = 1
			elif ara[i] < 0:
				neg = 1
		if flag == False:
			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()))
	memo = {0: 0, 1: 0, -1: 0}
	for i in range(n):
		memo[a[i]] += 1
	flag = True
	for i in range(n)[::-1]:
		memo[a[i]] -= 1
		if b[i] - a[i] == 0:
			pass
		elif b[i] - a[i] > 0:
			if memo[1] == 0:
				flag = False
		elif memo[-1] == 0:
			flag = False
	if flag:
		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()))
	flag = 'YES'
	Set = set()
	for i in range(n):
		if b[i] > a[i] and 1 not in Set or (b[i] < a[i] and -1 not in Set):
			flag = 'NO'
			break
		Set.add(a[i])
	print(flag)


for t in range(int(input())):
	num = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(pp, nn) = (0, 0)
	p = []
	n = []
	for i in range(num):
		if a[i] == 1:
			pp = pp + 1
			p.append(pp)
			n.append(nn)
		elif a[i] == -1:
			nn = nn + 1
			p.append(pp)
			n.append(nn)
		else:
			p.append(pp)
			n.append(nn)
	if a[0] != b[0]:
		print('NO')
		continue
	x = 0
	for i in range(num - 1, 0, -1):
		if a[i] < b[i] and p[i - 1] < 1:
			print('NO')
			x = 1
			break
		elif a[i] > b[i] and n[i - 1] < 1:
			print('NO')
			x = 1
			break
	if x == 0:
		print('YES')


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = True
	minus_one = False
	plus_one = False
	for j in range(n):
		if j == 0:
			if a[j] != b[j]:
				print('NO')
				flag = False
				break
		elif a[j] == b[j]:
			continue
		elif a[j] > b[j]:
			if minus_one:
				continue
			elif -1 in a[:j]:
				minus_one = True
				continue
			else:
				print('NO')
				flag = False
				break
		elif plus_one:
			continue
		elif 1 in a[:j]:
			plus_one = True
			continue
		else:
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	minusone = n
	one = n
	zero = n
	p = 0
	q = 0
	r = 0
	f = 0
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(n):
			if p == 0 and a[i] == 1:
				p = 1
				one = i
			elif q == 0 and a[i] == -1:
				q = 1
				minusone = i
			elif r == 0 and a[i] == 0:
				r = 1
				zero = i
			if p == 1 and r == 1 and (q == 1):
				break
		for i in range(n - 1, 0, -1):
			if b[i] > a[i]:
				if one >= i:
					f = 1
					break
			elif b[i] < a[i]:
				if minusone >= i:
					f = 1
					break
		if f == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	equi = True
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		if a[i] != b[i]:
			equi = False
	one = False
	neg = False
	possibility = True
	for i in range(n):
		if a[i] < b[i] and (not one):
			possibility = False
		if a[i] > b[i] and (not neg):
			possibility = False
		if a[i] == 1:
			one = True
		if a[i] == -1:
			neg = True
	if equi:
		possibility = True
	if possibility:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(num) for num in input().split()]
	b = [int(num) for num in input().split()]
	if a[0] != b[0]:
		print('NO')
	else:
		p1Enc = False
		m1Enc = False
		if a[0] == 1:
			p1Enc = True
		elif a[0] == -1:
			m1Enc = True
		i = 1
		while i < n:
			diff = b[i] - a[i]
			if diff > 0 and (not p1Enc):
				print('NO')
				break
			elif diff < 0 and (not m1Enc):
				print('NO')
				break
			if not p1Enc and a[i] == 1:
				p1Enc = True
			elif not m1Enc and a[i] == -1:
				m1Enc = True
			i += 1
		if i == n:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	x = -1
	y = -1
	z = -1
	for i in range(n):
		if l1[i] == 0:
			x = i
			break
	for i in range(n):
		if l1[i] == 1:
			y = i
			break
	for i in range(n):
		if l1[i] == -1:
			z = i
			break
	if l1[0] != l2[0]:
		print('NO')
	else:
		f = 0
		for i in range(1, n):
			if l1[i] != l2[i]:
				if l1[i] > l2[i]:
					if z == -1 or z >= i:
						f = 1
						break
				elif l1[i] < l2[i]:
					if y == -1 or y >= i:
						f = 1
						break
		if f == 1:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	flag1 = 0
	flag2 = 0
	flag3 = 0
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n == 1 and a[0] == b[0]:
		print('YES')
		continue
	if a[0] != b[0]:
		print('NO')
		continue
	for j in range(n):
		if a[j] == 1:
			flag2 = 1
			for k in range(j + 1):
				if b[k] - a[k] > 0:
					flag1 = 1
					break
			break
	if flag2 == 0:
		for k in range(n):
			if b[k] - a[k] > 0:
				flag1 = 1
				break
	for j in range(n):
		if a[j] == -1:
			flag3 = 1
			for k in range(j + 1):
				if b[k] - a[k] < 0:
					flag1 = 1
					break
			break
	if flag3 == 0:
		for k in range(n):
			if b[k] - a[k] < 0:
				flag1 = 1
				break
	if flag1 == 1:
		print('NO')
	else:
		print('YES')


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	fp = -1
	fn = -1
	for i in range(n):
		if l1[i] > 0:
			if fp == -1:
				fp = i
		elif l1[i] < 0:
			if fn == -1:
				fn = i
		if fp != -1 and fn != -1:
			break
	lol = 0
	for i in range(n):
		if l1[i] < l2[i]:
			if fp == -1 or fp >= i:
				lol = 1
				break
		if l1[i] > l2[i]:
			if fn == -1 or fn >= i:
				lol = 1
				break
	if lol:
		print('NO')
	else:
		print('YES')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	precount = []
	one_flag = False
	minus_one_flag = False
	for q in a1:
		precount.append((minus_one_flag, one_flag))
		if q == -1:
			minus_one_flag = True
		elif q == 1:
			one_flag = True
	result = True
	for j in range(n - 1):
		if a2[n - 1 - j] < a1[n - 1 - j] and precount[n - 1 - j][0] == False:
			result = False
			break
		elif a2[n - 1 - j] > a1[n - 1 - j] and precount[n - 1 - j][1] == False:
			result = False
			break
	if a1[0] != a2[0]:
		result = False
	if not result:
		print('NO')
	else:
		print('YES')


T = int(input())
for __ in range(T):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(inc, dec) = (False, False)
	failed = False
	for i in range(len(b)):
		if a[i] < b[i]:
			if inc == False:
				failed = True
		elif a[i] > b[i]:
			if dec == False:
				failed = True
		if a[i] == 1:
			inc = True
		elif a[i] == -1:
			dec = True
	if failed:
		print('NO')
	else:
		print('YES')


q = int(input())
for w in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	f = True
	if a[0] != b[0]:
		f = False
	else:
		h = {}
		h[a[0]] = 1
		for i in range(1, n):
			if a[i] == b[i]:
				h[a[i]] = 1
				continue
			elif b[i] > a[i]:
				if 1 not in h:
					f = False
					break
			elif -1 not in h:
				f = False
				break
			h[a[i]] = 1
	if f:
		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()))
	f = 0
	d = {}
	d[1] = -9
	d[0] = -9
	d[-1] = -9
	for i in range(len(a)):
		if a[i] == b[i]:
			pass
		if b[i] > a[i]:
			if d[1] == -9:
				print('NO')
				f = 1
				break
		if b[i] < a[i]:
			if d[-1] == -9:
				print('NO')
				f = 1
				break
		d[a[i]] = 1
	if f == 0:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	aPos = False
	aNeg = False
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		d = b[i] - a[i]
		if d != 0:
			if d > 0:
				if not aPos:
					print('NO')
					break
			elif not aNeg:
				print('NO')
				break
		if a[i] > 0:
			aPos = True
		elif a[i] < 0:
			aNeg = True
	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()))
	t1 = 0
	if a[0] != b[0]:
		print('NO')
		t1 = 1
	else:
		flag1 = 0
		flag2 = 0
		if a[0] == 1:
			flag2 = 1
		elif a[0] == -1:
			flag1 = 1
		for i in range(1, n):
			if b[i] > a[i]:
				if flag2 != 1:
					print('NO')
					t1 = 1
					break
				else:
					pass
			elif b[i] < a[i]:
				if flag1 != 1:
					print('NO')
					t1 = 1
					break
				else:
					pass
			if flag1 == 0:
				if a[i] == -1:
					flag1 = 1
			if flag2 == 0:
				if a[i] == 1:
					flag2 = 1
	if t1 == 0:
		print('YES')


def main():
	tc_count = int(input())
	for tc in range(tc_count):
		sol = 'YES'
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		mp = {1: 0, 0: 0, -1: 0}
		for x in a:
			mp[x] += 1
		idx = len(a) - 1
		for x in b[::-1]:
			mp[a[idx]] -= 1
			if a[idx] != b[idx]:
				if a[idx] > b[idx] and mp[-1] == 0:
					sol = 'NO'
					break
				elif a[idx] < b[idx] and mp[1] == 0:
					sol = 'NO'
					break
			idx -= 1
		print('{}'.format(sol))
main()


t = int(input())
for x in range(t):
	n = int(input())
	c = [0] * 3
	a = list((int(i) for i in input().split()))
	b = list((int(i) for i in input().split()))
	for i in range(n):
		c[a[i] + 1] += 1
	no = 0
	for i in range(n - 1, -1, -1):
		c[a[i] + 1] -= 1
		if a[i] > b[i]:
			if c[0] == 0:
				no = 1
		elif a[i] < b[i]:
			if c[2] == 0:
				no = 1
	print('YES' if no == 0 else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(c, d) = (0, 0)
	p = []
	k = 0
	if a[0] != b[0]:
		print('NO')
	else:
		for i in range(0, n - 1):
			if a[i] == -1:
				d = 1
				p.append(a[i])
			if a[i] == 1:
				c = 1
				p.append(a[i])
			if a[i + 1] == b[i + 1]:
				continue
			elif b[i + 1] == 0 and -1 * (b[i + 1] + a[i + 1]) // abs(b[i + 1] + a[i + 1]) in p or (b[i + 1] != 0 and b[i + 1] // abs(b[i + 1]) in p):
				k = 0
			else:
				k = 1
				break
		if k == 1:
			print('NO')
		else:
			print('YES')


def solve(n, a, b):
	if a[0] != b[0]:
		return 'NO'
	(add, minus) = (a[0] == 1, a[0] == -1)
	for i in range(1, n):
		if a[i] > b[i] and (not minus):
			return 'NO'
		if a[i] < b[i] and (not add):
			return 'NO'
		(add, minus) = (add or a[i] == 1, minus or a[i] == -1)
	return 'YES'

def main():
	inp = lambda : [int(x) for x in input().split()]
	tc = int(input())
	for _ in range(tc):
		n = int(input())
		(a, b) = (inp(), inp())
		print(solve(n, a, b))
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[0] != b[0]:
		print('NO')
		continue
	pos = 0
	neg = 0
	if a[0] == 1:
		pos = 1
	if a[0] == -1:
		neg = 1
	fl = 1
	for i in range(1, n):
		val = b[i] - a[i]
		if val > 0 and pos >= 1:
			fl = 1
		elif val < 0 and neg >= 1:
			fl = 1
		elif val != 0:
			fl = -1
			print('NO')
			break
		if a[i] == -1:
			neg += 1
		if a[i] == 1:
			pos += 1
	if fl != -1:
		print('YES')


for _ in range(int(input())):
	w = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	minIndex = -1
	maxIndex = -1
	for i in range(w):
		if a[i] == -1:
			minIndex = i
			break
	for i in range(w):
		if a[i] == 1:
			maxIndex = i
			break
	flag = True
	for i in range(w):
		if a[i] == b[i]:
			continue
		elif a[i] < b[i] and maxIndex < i and (maxIndex != -1) or (a[i] > b[i] and minIndex < i and (minIndex != -1)):
			continue
		else:
			flag = False
			break
	if flag == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	l = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	s = 0
	if a1[0] != a2[0]:
		print('NO')
		continue
	else:
		s += 1
		items_in = [0, 0, 0]
		items_in[a1[0]] = 1
		for i in range(1, l):
			if a1[i] > a2[i] and items_in[2] != 1:
				continue
			if a1[i] < a2[i] and items_in[1] != 1:
				continue
			s += 1
			items_in[a1[i]] = 1
	if s == l:
		print('YES')
	else:
		print('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')
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if 1 in a:
		ind1 = a.index(1)
	else:
		ind1 = n
	if -1 in a:
		ind_1 = a.index(-1)
	else:
		ind_1 = n
	c = []
	flag = 0
	for j in range(n):
		c.append(b[j] - a[j])
	if c.count(0) == n:
		print('YES')
		continue
	for j in range(n):
		if c[j] > 0:
			if ind1 < j:
				flag = 1
			else:
				flag = 0
				break
		if c[j] < 0:
			if ind_1 < j:
				flag = 1
			else:
				flag = 0
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	b = inputlist()
	one = False
	minusone = False
	if a[0] == 1:
		one = True
	if a[0] == -1:
		minusone = True
	if b[0] != a[0]:
		print('NO')
		continue
	done = False
	for i in range(1, n):
		if b[i] > a[i] and (not one):
			print('NO')
			done = True
			break
		elif b[i] < a[i] and (not minusone):
			print('NO')
			done = True
			break
		if a[i] == 1:
			one = True
		elif a[i] == -1:
			minusone = True
	if not done:
		print('YES')


from copy import deepcopy
import sys
input = sys.stdin.readline
(t,) = map(int, input().split())
for _ in range(t):
	(N,) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = [set()]
	tt = set()
	for i in range(N):
		tt.add(A[i])
		C.append(deepcopy(tt))
	for i in range(N - 1, -1, -1):
		c = B[i] - A[i]
		if c > 0 and 1 not in C[i]:
			print('NO')
			break
		if c < 0 and -1 not in C[i]:
			print('NO')
			break
	else:
		print('YES')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

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

def outln(var):
	sys.stdout.write(str(var) + '\n')

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	a = l()
	b = l()
	s = set()
	result = True
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif a[i] > b[i]:
			if -1 not in s:
				result = False
				break
		elif 1 not in s:
			result = False
			break
		s.add(a[i])
	if result:
		outln('YES')
		continue
	outln('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	pos = {}
	ans = 'YES'
	for i in range(n):
		if a[i] == 1:
			if 1 not in pos.keys():
				pos[1] = i
		if a[i] == -1:
			if -1 not in pos.keys():
				pos[-1] = i
	if 1 not in pos.keys():
		pos[1] = n + 1
	if -1 not in pos.keys():
		pos[-1] = n + 1
	for i in range(n):
		if a[i] != b[i] and i == 0:
			ans = 'NO'
			break
		elif i > pos[1] and i > pos[-1]:
			continue
		elif b[i] - a[i] == 0:
			continue
		elif b[i] - a[i] < 0:
			if i > pos[-1]:
				continue
			else:
				ans = 'NO'
				break
		elif i > pos[1]:
			continue
		else:
			ans = 'NO'
			break
	print(ans)


def main():
	T = int(input())
	for i in range(T):
		N = int(input())
		temp = input().split()
		a = []
		for i in temp:
			a.append(int(i))
		temp = input().split()
		b = []
		for i in temp:
			b.append(int(i))
		if a[0] != b[0]:
			print('NO')
		else:
			canIncrement = False
			canDecrement = False
			if a[0] > 0:
				canIncrement = True
			elif a[0] < 0:
				canDecrement = True
			failed = False
			for index in range(1, len(a)):
				if check_if_possible(a[index], b[index], canIncrement, canDecrement) is False:
					print('NO')
					failed = True
					break
				elif a[index] > 0:
					canIncrement = True
				elif a[index] < 0:
					canDecrement = True
			if failed is False:
				print('YES')

def check_if_possible(val_a, val_b, canIncrement, canDecrement):
	if int(val_a) == int(val_b):
		return True
	elif val_a < val_b and canIncrement is True:
		return True
	elif val_a > val_b and canDecrement is True:
		return True
	return False
main()


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = dict()
	ans = -2
	for i in range(0, n):
		d[i] = ans
		if a[i] == 1 and ans == -2:
			ans = 1
		elif a[i] == -1 and ans == -2:
			ans = -1
		if ans == -1 and a[i] == 1:
			ans = 0
		if ans == 1 and a[i] == -1:
			ans = 0
	f = 1
	for i in range(0, n):
		if a[i] < b[i] and (d[i] == 1 or d[i] == 0):
			f = 1
		elif a[i] > b[i] and (d[i] == -1 or d[i] == 0):
			f = 1
		elif a[i] == b[i]:
			f = 1
		else:
			f = 0
			break
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	MyCheck = {}
	N = int(input())
	First = list(map(int, input().split()))
	Second = list(map(int, input().split()))
	MyCheck[First[0]] = 1
	if First[0] != Second[0]:
		print('NO')
		continue
	Countinue = False
	for i in range(1, N):
		if Second[i] - First[i] > 0 and 1 not in MyCheck:
			Countinue = True
			break
		if Second[i] - First[i] < 0 and -1 not in MyCheck:
			Countinue = True
			break
		MyCheck[First[i]] = 1
	if Countinue:
		print('NO')
		continue
	print('YES')


import math
import sys
import itertools

def sa(Type=int):
	return [Type(x) for x in input().split()]

def solve(t):
	n = int(input())
	a = sa()
	b = sa()
	firstPosIdx = 10000000000.0
	firstNegIdx = 10000000000.0
	for (i, x) in enumerate(a):
		if x == 1:
			firstPosIdx = i
			break
	for (i, x) in enumerate(a):
		if x == -1:
			firstNegIdx = i
			break
	possible = True
	for (i, x) in enumerate(b):
		direction = x - a[i]
		if direction > 0 and i <= firstPosIdx or (direction < 0 and i <= firstNegIdx):
			possible = False
	print('YES' if possible else 'NO')
t = int(input())
for i in range(t):
	solve(i + 1)


t = int(input())
for i in range(t):
	flag = 0
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(y) for y in input().split(' ')]
	if a == b:
		print('YES')
		continue
	out = []
	pos = 0
	neg = 0
	for i in range(n):
		if pos == 0 and neg == 0:
			out.append('same')
		if pos == 1 and neg == 1:
			out.append('any')
			break
		if pos == 1 and neg == 0 and (a[i] <= 0):
			out.append('Zpos')
		if pos == 1 and neg == 0 and (a[i] > 0):
			out.append('pos')
		if neg == 1 and pos == 0 and (a[i] >= 0):
			out.append('Zneg')
		if neg == 1 and pos == 0 and (a[i] < 0):
			out.append('neg')
		if a[i] == 1:
			pos = 1
		if a[i] == -1:
			neg = 1
	for i in range(n):
		if out[i] == 'any':
			print('YES')
			flag = 1
			break
		if a[i] == b[i]:
			continue
		if out[i] == 'same':
			if a[i] != b[i]:
				print('NO')
				flag = 1
				break
		if out[i] == 'pos':
			if b[i] <= 0:
				flag = 1
				print('NO')
				break
		if out[i] == 'Zpos':
			if b[i] < 0:
				flag = 1
				print('NO')
				break
		if out[i] == 'neg':
			if b[i] >= 0:
				flag = 1
				print('NO')
				break
		if out[i] == 'Zneg':
			if b[i] > 0:
				flag = 1
				print('NO')
				break
	if flag == 0:
		print('YES')


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(1000000)
d = defaultdict(lambda : 0, {})

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

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

def o():
	return int(input())

def l(x):
	return len(x)

def r(x):
	if type(x) == int:
		return range(x)
	else:
		return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = float('inf')
MIN = -float('inf')
p = input
for _ in range(o()):
	n = o()
	(l1, l2) = (op(), op())
	(f1, f2) = (0, 0)
	l = [None] * len(l1)
	if l1[0] != l2[0]:
		print('NO')
		continue
	if l1[0] == 1:
		f1 = 1
	if l1[0] == -1:
		f2 = 1
	l[0] = (f1, f2)
	for i in range(1, len(l1)):
		l[i] = (f1, f2)
		if l1[i] == 1:
			f1 = 1
		if l1[i] == -1:
			f2 = 1
	for i in range(1, len(l)):
		x = l2[i] - l1[i]
		if x > 0:
			if l[i][0] == 0:
				print('NO')
				break
		elif x < 0:
			if l[i][1] == 0:
				print('NO')
				break
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	m = {-1: 0, 0: 0, 1: 0}
	for i in a:
		m[i] += 1
	valid = True
	for i in range(n - 1, -1, -1):
		m[a[i]] -= 1
		if a[i] != b[i]:
			if a[i] > b[i]:
				if m[-1] == 0:
					valid = False
					break
			elif m[1] == 0:
				valid = False
				break
	if valid:
		print('YES')
	else:
		print('NO')
	t -= 1


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	if arr[0] != brr[0]:
		print('NO')
	else:
		flag = True
		one = n + 1
		if 1 in arr:
			one = arr.index(1)
		mone = n + 1
		if -1 in arr:
			mone = arr.index(-1)
		for i in range(n - 1, 0, -1):
			diff = brr[i] - arr[i]
			if diff < 0 and mone >= i:
				flag = False
				break
			elif diff > 0 and one >= i:
				flag = False
				break
		if flag == False:
			print('NO')
		else:
			print('YES')


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	b = [int(x) for x in inp().split()]
	pos = False
	neg = False
	needPos = False
	needNeg = False
	skip = False
	for i in range(n):
		if b[i] < a[i] and neg == False:
			print('NO')
			skip = True
			break
		if b[i] > a[i] and pos == False:
			print('NO')
			skip = True
			break
		if a[i] == 1 and pos == False:
			pos = True
		if a[i] == -1 and neg == False:
			neg = True
	if not skip:
		print('YES')


import sys
input = sys.stdin.readline
ins = lambda : input()
ini = lambda : int(input())
inm = lambda : map(int, input().split())
inl = lambda : list(map(int, input().split()))
t = ini()
ans = []
for _ in range(t):
	n = ini()
	a = inl()
	b = inl()
	count = [0, 0]
	tmp = True
	for i in range(n):
		if a[i] > b[i] and count[1] == 0:
			tmp = False
			break
		elif a[i] < b[i] and count[0] == 0:
			tmp = False
			break
		if a[i] == 1:
			count[0] = 1
		if a[i] == -1:
			count[1] = 1
	ans.append('YES' if tmp else 'NO')
print('\n'.join(ans))


def solve(a, b):
	if a[0] != b[0]:
		return False
	hasOne = a[0] == 1
	hasMinusOne = a[0] == -1
	for i in range(1, len(a)):
		if a[i] == b[i]:
			pass
		elif b[i] > a[i] and hasOne:
			pass
		elif b[i] < a[i] and hasMinusOne:
			pass
		else:
			return False
		hasOne = hasOne or a[i] == 1
		hasMinusOne = hasMinusOne or a[i] == -1
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print('YES' if solve(a, b) else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(ele) for ele in input().split()]
	b = [int(ele) for ele in input().split()]
	hasnegative = False
	hasone = False
	for i in range(n):
		if a[i] > b[i] and (not hasnegative):
			print('NO')
			break
		if a[i] < b[i] and (not hasone):
			print('NO')
			break
		if a[i] == 1:
			hasone = True
		if a[i] == -1:
			hasnegative = True
	else:
		print('YES')


test = input()
test = int(test)
for t in range(test):
	n = input()
	n = int(n)
	doable = True
	ai = input().split()
	for i in range(n):
		ai[i] = int(ai[i])
	bi = input().split()
	for v in range(n):
		bi[v] = int(bi[v])
	partials = []
	psum = 0
	for w in range(n):
		if ai[w] == 1:
			psum += n
		elif ai[w] == -1:
			psum += 1
		partials.append(psum)
	for j in range(n):
		k = n - 1 - j
		if k == 0:
			if ai[k] != bi[k]:
				doable = False
			break
		if bi[k] > ai[k] and partials[k - 1] < n:
			doable = False
		elif bi[k] < ai[k] and partials[k - 1] % n == 0:
			doable = False
	if doable:
		print('YES')
	else:
		print('NO')


def solve(a, b):
	(up, down) = (False, False)
	for j in range(n):
		if a[j] == 1:
			if b[j] == 1:
				up = True
			elif b[j] < a[j] and down:
				up = True
		if a[j] == -1:
			if b[j] == -1:
				down = True
			elif b[j] > a[j] and up:
				down = True
		if a[j] < b[j] and (not up):
			print('NO')
			return
		elif a[j] > b[j] and (not down):
			print('NO')
			return
	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(' ')))
	solve(a, b)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'YES'
	set1 = set()
	for i in range(n):
		if a[i] != b[i]:
			diff = b[i] - a[i]
			if diff > 0:
				if 1 not in set1:
					ans = 'NO'
					break
			elif -1 not in set1:
				ans = 'NO'
				break
			set1.add(a[i])
		else:
			set1.add(a[i])
	print(ans)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	minus = []
	plus = []
	zero = []
	if a[0] == 1:
		plus.append(1)
	else:
		plus.append(0)
	if a[0] == -1:
		minus.append(1)
	else:
		minus.append(0)
	if a[0] == 0:
		zero.append(1)
	else:
		zero.append(0)
	for i in range(1, n):
		if a[i] == -1:
			minus.append(1)
		else:
			minus.append(minus[i - 1])
		if a[i] == 1:
			plus.append(1)
		else:
			plus.append(plus[i - 1])
		if a[i] == 0:
			zero.append(1)
		else:
			zero.append(zero[i - 1])
	ans = 1
	for i in range(n - 1, 0, -1):
		if b[i] == a[i]:
			continue
		elif b[i] > a[i]:
			if plus[i - 1]:
				continue
			else:
				ans = 0
		elif b[i] < a[i]:
			if minus[i - 1]:
				continue
			else:
				ans = 0
	if b[0] != a[0]:
		ans = 0
	if ans:
		print('YES')
	else:
		print('NO')


def answer(n, A, B):
	d = {0: 0, 1: 0, -1: 0}
	for i in range(n):
		d[A[i]] += 1
	for i in range(len(A) - 1, -1, -1):
		d[A[i]] -= 1
		if A[i] > B[i]:
			if d[-1] <= 0:
				return 'NO'
		elif A[i] < B[i]:
			if d[1] <= 0:
				return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(answer(n, a, b))


t = int(input())
for i in range(t):
	n = int(input())
	move = [int(i) for i in input().split()]
	compair = [int(i) for i in input().split()]
	backNeg = backPos = False
	ans = True
	for j in range(n):
		if move[j] == compair[j]:
			if move[j] > 0:
				backPos = True
			elif move[j] < 0:
				backNeg = True
			continue
		if move[j] < compair[j]:
			if not backPos:
				ans = False
				break
		if move[j] > compair[j]:
			if not backNeg:
				ans = False
				break
		if move[j] > 0:
			backPos = True
		elif move[j] < 0:
			backNeg = True
	print('YES' if ans else 'NO')


t_case = int(input())
while t_case > 0:
	t_case -= 1
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	checkNegative = False
	checkPositve = False
	no = False
	if a[0] != b[0]:
		print('NO')
		continue
	for i in range(1, n):
		if a[i - 1] > 0:
			checkPositve = True
		elif a[i - 1] < 0:
			checkNegative = True
		if b[i] == a[i]:
			continue
		if b[i] == 0:
			if a[i] > 0 and (not checkNegative):
				no = True
				break
			elif a[i] < 0 and (not checkPositve):
				no = True
				break
		if b[i] > 0 and (not checkPositve):
			no = True
			break
		if b[i] < 0 and (not checkNegative):
			no = True
			break
	if no:
		print('NO')
	else:
		print('YES')


from math import *
from bisect import bisect_left, bisect_right
from sys import stdin, stdout
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		if a[i] != 0:
			break
	else:
		for i in b:
			if i > 0 or i < 0:
				print('NO\n')
				break
		else:
			print('YES\n')
		continue
	for j in range(i + 1, n):
		if a[j] == -a[i]:
			break
	else:
		j = n - 1
	for k in range(i + 1):
		if b[k] != a[k]:
			print('NO\n')
			break
	else:
		for k in range(i + 1, j + 1):
			if a[i] == 1 and b[k] < a[k]:
				print('NO\n')
				break
			if a[i] == -1 and b[k] > a[k]:
				print('NO\n')
				break
		else:
			print('YES\n')


import math
from sys import setprofile, stdin

def ii():
	return int(stdin.readline().strip())

def ff():
	return float(stdin.readline().strip())

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

def ari():
	return list(map(int, stdin.readline().split()))

def arf():
	return list(map(float, stdin.readline().split()))

def ars():
	return list(map(str, stdin.readline().split()))

def matrix(n):
	return [ari() for _ in range(n)]

def main():
	n = ii()
	a = ari()
	b = ari()
	if a[0] != b[0]:
		print('NO')
		return
	s = set()
	s.add(a[0])
	for i in range(1, n):
		if a[i] < b[i] and 1 not in s:
			print('NO')
			return
		elif a[i] > b[i] and -1 not in s:
			print('NO')
			return
		s.add(a[i])
	print('YES')
t = 1
t = ii()
for _ in range(t):
	main()


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


def solve():
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = 0
	b = 0
	if l1[0] != l2[0]:
		print('NO')
		return
	if l1[0] > 0:
		a = 1
	elif l1[0] < 0:
		b = 1
	for i in range(1, n):
		if l1[i] < l2[i]:
			if a != 1:
				print('NO')
				return
		elif l1[i] > l2[i]:
			if b != 1:
				print('NO')
				return
		if l1[i] > 0:
			a = 1
		elif l1[i] < 0:
			b = 1
	print('YES')
	return
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	try:
		minus = a.index(-1)
	except:
		minus = float('inf')
	try:
		plus = a.index(1)
	except:
		plus = float('inf')
	ans = 1
	for i in range(n):
		if a[i] < b[i]:
			if plus >= i:
				ans = 0
				break
		elif a[i] > b[i]:
			if minus >= i:
				ans = 0
				break
	if ans == 0:
		print('NO')
	else:
		print('YES')


import bisect, collections

def solution():
	n = int(input().strip())
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	(hasPlus, hasMinus) = (False, False)
	for i in range(n):
		if a[i] > b[i] and (not hasMinus) or (a[i] < b[i] and (not hasPlus)):
			print('NO')
			return
		if a[i] == 1:
			hasPlus = True
		if a[i] == -1:
			hasMinus = True
	print('YES')

def main():
	T = int(input().strip())
	for _ in range(T):
		solution()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	res = []
	A = list(map(int, input().strip().split()))[:n]
	B = list(map(int, input().strip().split()))[:n]
	if A[0] != B[0]:
		print('NO')
		continue
	neg = 0
	pos = 0
	flag = 0
	if A[0] == 1:
		pos = 1
	elif A[0] == -1:
		neg = 1
	for i in range(1, n):
		if pos == 1 and neg == 1:
			flag = 0
			break
		if B[i] > A[i] and pos == 0:
			flag = 1
			break
		if B[i] < A[i] and neg == 0:
			flag = 1
			break
		if A[i] == 1:
			pos = 1
		elif A[i] == -1:
			neg = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


def solve(A, B):
	n = len(A)
	appr = {-1: 0, 0: 0, 1: 0}
	for a in A:
		appr[a] += 1
	for (i, (a, b)) in enumerate(zip(A[::-1], B[::-1])):
		appr[a] -= 1
		if b > a and appr[1] < 1:
			return False
		elif b == a:
			continue
		elif b < a and appr[-1] < 1:
			return False
	return True
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()]
	assert len(A) == n and len(B) == n
	poss = solve(A, B)
	print('YES' if poss else 'NO')


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

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

def li():
	return list(mi())

def si():
	return input()

def main():
	for _ in range(ii()):
		pos = 0
		neg = 0
		n = ii()
		a = li()
		b = li()
		f = 0
		for i in range(n):
			if b[i] > a[i]:
				if pos == 0:
					f = 1
					break
			if b[i] < a[i]:
				if neg == 0:
					f = 1
					break
			if a[i] > 0:
				pos += 1
			if a[i] < 0:
				neg += 1
		if f:
			print('NO')
		else:
			print('YES')
main()


for p in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag1 = False
	flag2 = False
	c = 0
	if a[0] != b[0]:
		print('NO')
	else:
		if a[0] == 1:
			flag1 = True
		if a[0] == -1:
			flag2 = True
		for i in range(1, n):
			x = b[i] - a[i]
			if x > 0:
				if flag1 == False:
					print('NO')
					c = 1
					break
			elif x < 0 and flag2 == False:
				print('NO')
				c = 1
				break
			if a[i] == 1:
				flag1 = True
			elif a[i] == -1:
				flag2 = True
		if c != 1:
			print('YES')