#P7625. [2018年杭电多校]K-Similar Strings

[2018年杭电多校]K-Similar Strings

K-Similar Strings

Problem Description

Acesrc loves solving string problems. He defined a relation called k-similarity\textit{k-similarity} between two nonempty\textbf{nonempty} strings. The definition of kk-similarity is shown below:

  1. for nonempty string SS, SS and SS are kk-similar;
  2. for two nonempty strings SS and TT with S+Tk|S| + |T| \leq k, if STS \circ T and TST \circ S are kk-similar (\circ denotes string concatenation), then SS and TT are kk-similar;
  3. if SS and TT are kk-similar, then PSQP \circ S \circ Q and PTQP \circ T \circ Q are kk-similar, where PP and QQ are arbitrary (possibly empty) strings;
  4. if SS and UU are kk-similar, UU and TT are kk-similar, then SS and TT are kk-similar. For example, aaa\texttt{aaa} and aaa\texttt{aaa} are 3-similar according to the the first condition. Hence, a\texttt{a} and aa\texttt{aa} are 3-similar according to the second condition. Moreover, ba\texttt{ba} and baa\texttt{baa}, baa\texttt{baa} and baaa\texttt{baaa} are also 3-similar, respectively, according to the third condition. Finally, ba\texttt{ba} and baaa\texttt{baaa} are 3-similar, according to the fourth condition. Now, given two strings A,BA, B and an integer kk, please determine whether AA and BB are kk-similar.

Input

The first line of the input is a single integer TT (1T5000)(1 \leq T \leq 5000), denoting the number of test cases. Each test case contains three lines, which represent kk (1k106)(1 \leq k \leq 10^6), AA, BB, respectively. It is guaranteed that AA and BB contain only lowercase letters 'a'-'z' and the lengths of AA and BB are between 1 and 2×1052 \times 10^5, inclusive. It is further guaranteed that the sum of lengths of AA and BB in all test cases does not exceed 3×1063 \times 10^6.

Output

For each test case, display a single line: yes\texttt{yes} if AA and BB are kk-similar, or no\texttt{no} if they are not.

Sample Input

4

3

ba

baa

2

aab

ab

1

acesrc

acesrc

100

roundgod

zyb

Sample Output

yes

no

yes

no

Source

2018 Multi-University Training Contest 8