#K69167. Valid List Shuffle

    ID: 33027 Type: Default 1000ms 256MiB

Valid List Shuffle

Valid List Shuffle

Given an original list of integers and a shuffled list, determine whether the shuffled list is a valid shuffle of the original list. A valid shuffle is defined as a shuffle where:

$$\text{shuffled} \neq \text{original} \quad \text{and} \quad \text{sorted(original)} = \text{sorted(shuffled)}.$$

Your task is to process multiple test cases. For each test case, if the shuffled list is a valid shuffle according to the above conditions, output YES; otherwise, output NO.

inputFormat

The first line contains an integer T, the number of test cases.

Each test case is described in three lines:

  • The first line contains an integer N, the number of elements in the lists.
  • The second line contains N space-separated integers representing the original list.
  • The third line contains N space-separated integers representing the shuffled list.

outputFormat

For each test case, output a single line containing either YES if the shuffled list is a valid shuffle, or NO otherwise.

## sample
6
5
1 2 3 4 5
2 3 1 5 4
4
1 2 3 4
1 2 3 4
6
1 1 2 2 3 3
3 1 2 1 2 3
2
1 2
2 1
3
1 2 3
1 3 2
3
4 4 4
4 4 4
YES

NO YES YES YES NO

</p>