题目描述
You are given sequences of positive integers of length $N$: $A=(A_1,A_2,\dots,A_N)$ and $B=(B_1,B_2,\dots,B_N)$.
You can repeat the following operation any number of times (possibly zero).
- Choose an integer $i$ such that $1 \le i \le N$ and replace $A_i$ with $A_{i+1}$.
Here, regard $A_{N+1}$ as $A_1$.
Determine whether it is possible to make $A$ equal $B$.
You have $T$ test cases to solve.
输入格式
The input is given from Standard Input in the following format:
>$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is in the following format:
>$N$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_N$
#### Constraints
- $1 \le T \le 5000$
- $1 \le N \le 5000$
- $1 \le A_i,B_i \le N$
- For each input file, the sum of $N$ over all test cases does not exceed $5000$.