#C4802. Make Arrays Identical

    ID: 48381 Type: Default 1000ms 256MiB

Make Arrays Identical

Make Arrays Identical

You are given two integer arrays \(a\) and \(b\), each containing \(n\) elements. You are allowed to reorder the elements of array \(a\) arbitrarily. Determine whether it is possible to make array \(a\) identical to array \(b\). In other words, check whether the two arrays have the same multiset of elements.

The mathematical condition to check is whether \[ \text{sort}(a) = \text{sort}(b), \] where \(\text{sort}(x)\) denotes the sorted order of the array \(x\).

inputFormat

The first line of input contains an integer \(T\) representing the number of test cases. For each test case, the input consists of three lines:

  • The first line contains an integer \(n\), the number of elements in the arrays.
  • The second line contains \(n\) space-separated integers representing the array \(a\).
  • The third line contains \(n\) space-separated integers representing the array \(b\).

outputFormat

For each test case, output a single line containing "YES" if array \(a\) can be rearranged to become identical to array \(b\), and "NO" otherwise.

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

NO YES

</p>