405485: GYM101972 K Cyclic Shift

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Cyclic Shifttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given two strings a and b of the same length and consisting of lowercase English letters. You can pick at most one subsequence of string b and do a cyclic shift on that subsequence exactly once.

For example, if you have a string "abcdefg" and you picked the letters at indices 2, 5, and 6 as a subsequence to do a cyclic shift on them, the letter at index 2 will go to index 5, the letter at index 5 will go to index 6, the letter at index 6 will go to index 2, and the string will become "afcdbeg".

Your task is to check if it is possible to make string b equivalent to string a using at most one cyclic shift. Can you?

Input

The first line contains an integer T (1 ≤ T ≤ 200) specifying the number of test cases.

The first line of each test case contains an integer n (1 ≤ n ≤ 105) specifying the length of strings a and b. Then two lines follow, giving strings a and b, respectively. Both strings consist only of lowercase English letters.

Output

For each test case, print a single line containing "YES" (without quotes) if it is possible to make string b equivalent to string a using at most one cyclic shift. Otherwise, print "NO" (without quotes).

ExampleInput
2
6
abcdef
adcebf
4
abcd
dabd
Output
YES
NO
Note

A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. For example, the sequence is a subsequence of obtained after removal of elements , , and .

加入题单

上一题 下一题 算法标签: