Array transformation (change)

Description


There are two integer arrays \(A\) and \(B\) of length \(n\). The value of the array \(A\) will only be \(1, 0\) or \(-1\).
You can perform the following operations multiple times:
1. Choose any ordered pair \(\text{(i,j)}\) such that \(1\le i \lt j \le n\). You can select the same ordered pair \(\text{(i,j)}\) multiple times.
2. Add \(A[i]\) to \(A[j]\), that is, the \(j\) element of the array \(A\) is equal to \(A[i]+A[j]\).
For example, if the given array \(A\) is \([1,−1,0]\), you can transform it into \([1,−1,−1]\), \([1,0,0]\) and \([1,−1,1]\)in one operation.
The problem now is, given the arrays \(A\) and \(B\), determine whether a certain number (\(0\) or more) of these operations can be applied to the array \(A\) to make it equal to the array \(B\).

Format


Input

Contains multiple sets of test data. An integer \(T\) in the first line indicates the number of test data sets. Each set of test data contains:
The first line contains an integer \(n\), which represents the length of the array.
The second line contains \(n\) integers \(A[1], A[2], \cdots, A[n](-1\le A[i] \le 1)\) describe the \(A\) array.
The third line contains \(n\) integers \(B[1], B[2], \cdots, B[n](-10^9 \le B[i] \le 10^9)\) description array \(B\) .

Output

For each set of data output one line, if the arrays \(A\) and \(B\) can be made equal by performing the operations in the title description, then output YES, otherwise output NO.

Sample


Input

2
3
1 -1 0
1 1 -2
3
0 1 1
0 2 2

Output

YES
NO

Sample Explanation

In the first set of data, select the ordinal pair \(\text{(2,3)}\) to execute \(2\) times, and select the ordinal number pair \(\text{(1,2)}\) to execute \(2\) times, then the array \(A\) becomes the same as the array \(B\).

Hint


Data for \(100\%\): \(1 \le T \le 10000, 1 \le n \le 10^5\), make sure that the sum of \(n\) in multiple sets of data for each test point does not exceed \(10^5\).

Sample Code


Code is not available!
posted @   Sample_Test  阅读(176)  评论(0编辑  收藏  举报
编辑推荐:
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
· .NET 进程 stackoverflow异常后,还可以接收 TCP 连接请求吗?
阅读排行:
· 本地部署 DeepSeek:小白也能轻松搞定!
· 基于DeepSeek R1 满血版大模型的个人知识库,回答都源自对你专属文件的深度学习。
· 在缓慢中沉淀,在挑战中重生!2024个人总结!
· 大人,时代变了! 赶快把自有业务的本地AI“模型”训练起来!
· Tinyfox 简易教程-1:Hello World!
点击右上角即可分享
微信分享提示