------
## 最终结论
```python
def can_transform(a, b, n):
    has_positive = has_negative = False
    for i in range(n):
        if a[i] == 1:
            has_positive = True
        if a[i] == -1:
            has_negative = True
        if b[i] > a[i] and not has_positive:
            return "NO"
        if b[i] < a[i] and not has_negative:
            return "NO"
    return "YES"

def solve():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    index = 0
    t = int(data[index])
    index += 1
    
    results = []
    
    for _ in range(t):
        n = int(data[index])
        index += 1
        
        a = list(map(int, data[index:index + n]))
        index += n
        
        b = list(map(int, data[index:index + n]))
        index += n
        
        result = can_transform(a, b, n)
        results.append(result)
    
    for result in results:
        print(result)
```