J. Triple Reverse Sort

Time limit: 1s
Memory limit: 256MB
Input:
Output:

You are given a permutation aa of length nn.

On this permutation, we can perform the following operation multiple times:

  1. Select an index ii such that 1in21 \le i \le n-2;
  2. Reverse the subarray [ai,ai+1,ai+2][a_i,a_{i+1},a_{i+2}].

Is it possible to sort the permutation?

A permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

Input

Each test contains multiple testcases. The first line of each testcase contains an integer tt (1t1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains one integer nn (1n21051 \le n \le 2 \cdot 10^5) — the length of permutation aa.

The second line of each testcase contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ain1 \le a_i \le n, all aia_i are pairwise distinct) — the elements of permutation aa.

It is guaranteed that the sum of nn across all testcases does not exceed 21052 \cdot 10^5.

Output

For each testcase, print YES if aa can be sorted, or NO otherwise.

Example

stdin

6
1
1
2
2 1
3
3 2 1
4
4 3 2 1
5
1 3 2 5 4
5
3 4 5 2 1

stdout

YES
NO
YES
NO
NO
YES

Note

In the first two testcases, no operations can be performed since n<3n \lt 3. [1][1] is already sorted, while [2,1][2,1] is not.

In the third testcase, the permutation can be sorted by choosing i=1i=1 and reversing [a1,a2,a3][a_1,a_2,a_3].

In the fourth and fifth testcases, it can be proven that aa cannot be sorted.

Log in or sign up to be able to send submissions!