-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1333B.py
More file actions
28 lines (26 loc) · 701 Bytes
/
1333B.py
File metadata and controls
28 lines (26 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class solve:
def __init__(self):
for i in range(int(input())):
self.solution()
def solution(self):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
id,idx=float('inf'),float('inf')
for i in range(n):
if a[i]==1:
id=i
break
for i in range(n):
if a[i]==-1:
idx=i
break
for i in range(n):
if a[i]<b[i] and id>=i:
print("NO")
return
elif a[i]>b[i] and idx>=i:
print("NO")
return
print("YES")
obj=solve()