CF2244C Stepan and Permutation
Description
Stepan found a permutation $ p $ of length $ n $ . Of course, he decided to sort it. To make the process more interesting, he chose two positive integers $ x $ and $ y $ $ (x + y \le n) $ and defined a rule for swapping elements.
In one move, Stepan can choose two indices $ i $ and $ j $ $ (1 \le i, j \le n) $ and swap the elements $ p_i $ and $ p_j $ if at least one of the following conditions holds:
- $ |i - j| = x $
- $ |i - j| = y $
Stepan wants to know whether it is possible to sort the permutation in ascending order using any number of such operations. Help him answer this question.
Input Format
The first line contains a single integer $ t $ $ (1 \le t \le 10^4) $ — the number of test cases.
The first line of each test case contains three integers $ n $ , $ x $ , and $ y $ $ (1 \le x, y \le n \le 2 \cdot 10^5 $ , $ x + y \le n) $ — the length of the array and the numbers chosen by Stepan.
The second line of each test case contains $ n $ integers $ p_i $ $ (1 \le p_i \le n) $ — the array $ p $ ; it is guaranteed that $ p $ is a permutation.
It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 2 \cdot 10^5 $ .
Output Format
For each test case, output "YES" if it is possible to sort the permutation with the given $ x $ and $ y $ , and "NO" otherwise.
You may output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted.