#K36747. Transformable Strings

    ID: 25823 Type: Default 1000ms 256MiB

Transformable Strings

Transformable Strings

You are given two strings: an initial string and a target string. Your task is to determine whether the initial string can be transformed into the target string by reordering its characters.

Note: The transformation is possible if and only if both strings consist of the same multiset of characters. In other words, if you denote the two strings as \(S\) and \(T\), then the transformation is possible if \(\text{sort}(S) = \text{sort}(T)\).

inputFormat

The input begins with an integer \(T\) representing the number of test cases. Each test case consists of three lines:

  1. The first line contains an integer \(n\) (the length of the strings, \(1 \leq n \leq 10^5\)).
  2. The second line contains the initial string (a sequence of lowercase letters).
  3. The third line contains the target string (a sequence of lowercase letters).

outputFormat

For each test case, print a single line containing "YES" if the initial string can be transformed into the target string, and "NO" otherwise.

## sample
3
5
abcde
cdeab
4
abcd
dcba
3
xyz
yza
YES

YES NO

</p>