## GUPTA MECHANICAL

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

# [Solution] Madoka and Formal Statement Codeforces Solution

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Given an array of integer ${a}_{1},{a}_{2},\dots ,{a}_{n}$. In one operation you can make ${a}_{i}:={a}_{i}+1$ if $i and ${a}_{i}\le {a}_{i+1}$, or $i=n$ and ${a}_{i}\le {a}_{1}$.

You need to check whether the array ${a}_{1},{a}_{2},\dots ,{a}_{n}$ can become equal to the array ${b}_{1},{b}_{2},\dots ,{b}_{n}$ in some number of operations (possibly, zero). Two arrays $a$ and $b$ of length $n$ are called equal if ${a}_{i}={b}_{i}$ for all integers $i$ from $1$ to $n$.

Input

The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le 4\cdot {10}^{4}$) — the number of test cases. Description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2\le n\le 2\cdot {10}^{5}$) – the length of the array.

The second line of each test case contains $n$ integers ${a}_{1},\dots ,{a}_{n}$ ($1\le {a}_{i}\le {10}^{9}$) – the elements of the array $a$.

The third line of each test case contains $n$ integers ${b}_{1},\dots ,{b}_{n}$ ($1\le {b}_{i}\le {10}^{9}$) – the elements of the array $b$.

Solution Click Below:-  👉
👇👇👇👇👇

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

Output

For each test case, output "YES" if you can get the array $b$, otherwise output "NO".

You may print each letter in any case (for example, "YES", "Yes", "yes", "yEs" will all be recognized as positive answer).

Note

In the first test case, the array $a$ is already equal to the array $b$.

In the second test case, we can't get the array $b$, because to do this we need to decrease ${a}_{1}$.

In the fifth test case, we can apply operations in order to the elements with indices $4,3,3,2,2,2,1,1,1,1$, and then get the array $\left[5,5,5,5,5\right]$. After that, you can apply operations in order to elements with indices $5,4,4,3,1$ and already get an array $\left[6,5,6,7,6\right]$.