#P1730D. Prefixes and Suffixes
Prefixes and Suffixes
Description
You have two strings and of length , consisting of lowercase English letters. You can perform the following operation any (possibly zero) number of times:
- Choose a positive integer .
- Swap the prefix of the string and the suffix of the string of length .
Is it possible to make these two strings equal by doing described operations?
The first line contains a single integer () — the number of test cases. Then the test cases follow.
Each test case consists of three lines.
The first line contains a single integer () — the length of the strings and .
The second line contains the string of length , consisting of lowercase English letters.
The third line contains the string of length , consisting of lowercase English letters.
It is guaranteed that the sum of for all test cases does not exceed .
For each test case, print "YES" if it is possible to make the strings equal, and "NO" otherwise.
Input
The first line contains a single integer () — the number of test cases. Then the test cases follow.
Each test case consists of three lines.
The first line contains a single integer () — the length of the strings and .
The second line contains the string of length , consisting of lowercase English letters.
The third line contains the string of length , consisting of lowercase English letters.
It is guaranteed that the sum of for all test cases does not exceed .
Output
For each test case, print "YES" if it is possible to make the strings equal, and "NO" otherwise.
Samples
Note
In the first test case:
- Initially , .
- Operation with , after the operation , .
In the second test case:
- Initially , .
- Operation with , after the operation , .
- Operation with , after the operation , .
- Operation with , after the operation , .
- Operation with , after the operation , .
- Operation with , after the operation , .
- Operation with , after the operation , .
In the third test case, it's impossible to make strings equal.