#abc296f. [abc296_f]Simultaneous Swap
[abc296_f]Simultaneous Swap
Problem Statement
You are given two sequences of numbers: and .
Takahashi can repeat the following operation any number of times (possibly zero).
Choose three pairwise distinct integers , , and between and .
Swap the -th and -th elements of , and swap the -th and -th elements of .
If there is a way for Takahashi to repeat the operation to make and equal, print Yes
; otherwise, print No
.
Here, and are said to be equal when, for every , the -th element of and that of are equal.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if there is a way for Takahashi to repeat the operation to make and equal, and print No
otherwise.
Sample Input 1
3
1 2 1
1 1 2
Sample Output 1
Yes
Performing the operation once with swaps and , and swaps and ,
making both and equal to . Thus, you should print Yes
.
Sample Input 2
3
1 2 2
1 1 2
Sample Output 2
No
There is no way to perform the operation to make and equal, so you should print No
.
Sample Input 3
5
1 2 3 2 1
3 2 2 1 1
Sample Output 3
Yes
Sample Input 4
8
1 2 3 4 5 6 7 8
7 8 5 6 4 3 1 2
Sample Output 4
No