## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Array Decrements Codeforces Solution

B. Array Decrements
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Kristina has two arrays $a$ and $b$, each containing $n$ non-negative integers. She can perform the following operation on array $a$ any number of times:

• apply a decrement to each non-zero element of the array, that is, replace the value of each element ${a}_{i}$ such that ${a}_{i}>0$ with the value ${a}_{i}-1$ ($1\le i\le n$). If ${a}_{i}$ was $0$, its value does not change.

Determine whether Kristina can get an array $b$ from an array $a$ in some number of operations (probably zero). In other words, can she make ${a}_{i}={b}_{i}$ after some number of operations for each $1\le i\le n$?

For example, let $n=4$$a=\left[3,5,4,1\right]$ and $b=\left[1,3,2,0\right]$. In this case, she can apply the operation twice:

• after the first application of the operation she gets $a=\left[2,4,3,0\right]$;
• after the second use of the operation she gets $a=\left[1,3,2,0\right]$.

Thus, in two operations, she can get an array $b$ from an array $a$.

Input

The first line of the input contains an integer $t$ ($1\le t\le {10}^{4}$) —the number of test cases in the test.

The descriptions of the test cases follow.

The first line of each test case contains a single integer $n$ ($1\le n\le 5\cdot {10}^{4}$).

The second line of each test case contains exactly $n$ non-negative integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($0\le {a}_{i}\le {10}^{9}$).

The third line of each test case contains exactly $n$ non-negative integers ${b}_{1},{b}_{2},\dots ,{b}_{n}$ ($0\le {b}_{i}\le {10}^{9}$).

It is guaranteed that the sum of $n$ values over all test cases in the test does not exceed $2\cdot {10}^{5}$.

Output

For each test case, output on a separate line:

• YES, if by doing some number of operations it is possible to get an array $b$ from an array $a$;
• NO otherwise.

You can output YES and NO in any case (for example, strings yEsyesYes and YES will be recognized as a positive response).