Awkward operation

3

1 votes
Algorithms, Merge Sort, Sorting
Problem

You are given two sequences  a and b consisting of n integers. You may choose any index i (1<i<n) and simultanously apply the following changes :

  • ai1:=ai1+ai
  • ai:=ai
  • ai+1:=ai+1+ai

Determine whether you can make array a equal to array b after applying this operation any number of times (possibly zero).

Input

The first line contains one integer t (1t105)  --- the number of test cases.

The first line of each test case contains a single integer n (1n3105)--- the number of integers in each sequence.

The second line of each test case contains n integers a1,a2,...,an (109ai109).

The third line of each test case contains n integers b1,b2,...,bn(109bi109).

Output

For each test case, output "Yes" (without quotes) if b can be obtained by applying the aforementioned operation on a any number of times, and "No" (without quotes) otherwise.

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In the first test case, we can obtain array [5,1,3] by applying the operation on index i=2.

In the first test case, we can obtain array [3,0,2,5] by applying the operation on index i=3.

Editor Image

?