FIICode 2024 Open | Zalmahar's Business

This was the problem page during the contest. Access the current page here.
Time limit: 1s Memory limit: 256MB Input: Output:

Zalmahar, tired of using dark magic against his enemies, decides to take a break from his tumultuous life and withdraw into solitude. However, he is eager to make some gold while leading a quieter life, so he decides to venture into the crystal business, an old passion of his. Here's how his business operates: individuals send him a set number of crystals (nn), each possessing a specific energy (aia_i), with the desire to attain a particular energy configuration to emit a desired feng-shui. However, Zalmahar knows only one technique for achieving this: he can transfer energy to a designated crystal by aggregating the energies of nearby gemstones.

Formally, the crystals that he receives can be represented as a vector aa, where aia_i represents the power of each crystal for every 1in1 \le i \le n. Zalmahar's operation involves adjusting the energy of a crystal according to the formula ak=ak1+ak+ak+1a_k = a_{k - 1} + a_k + a_{k + 1}, where 1<k<n1 < k < n. Assist Zalmahar in determining whether he can generate an array bb consisting of nn elements to fulfill the specified commands.
Operations are performed on a single crystal at a time. You can perform as many operations as you want, even multiple times on the same crystal.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t1031 \le t \le 10^3) – the number of test cases. Then follows the description of the test cases.

The first line of each test case contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5) – the length of the array aa.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9) – the elements of the array aa.

The third line of each test case contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n (1bi1091 \le b_i \le 10^9) – the elements of the array bb.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output YES or NO.

Example 1

stdin

3
5
1 4 3 5 6
1 34 25 14 6
7
1 1 1 1 1 1 1
1 3 5 7 9 11 1
8
1 3 5 4 2 2 1 6
6 9 5 4 8 11 1 6

stdout

YES
YES
NO

Log in or sign up to be able to send submissions!