#arc136b. [arc136_b]Triple Shift
[arc136_b]Triple Shift
Problem Statement
You are given integer sequences of length each: and .
You can repeat the following operation any number of times.
- Choose an integer () and let be the current values of , respectively. Then, replace the values of with , respectively.
Determine whether it is possible to make equal .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make equal , print Yes
; otherwise, print No
.
Sample Input 1
4
3 1 4 5
4 1 5 3
Sample Output 1
Yes
We should do the following.
- Initially, we have .
- Do the operation with , making .
- Do the operation with , making .
- Do the operation with , making .
Sample Input 2
3
1 2 2
2 1 2
Sample Output 2
Yes
Sample Input 3
3
1 2 3
2 3 4
Sample Output 3
No