#GYM104679G. Winter Gifts
Winter Gifts
Description
At the beginning of the winter season in 2022, Ayon and Lagno received two colorful scarves as gifts from their mother. The scarves each have their own color patterns which can be described as a string of letters where each letter identifies as a unique color. Lagno was worried that her scarf would not match her brother's, but fortunately, she found a way to modify the colors on her own scarf.
Consider the color pattern of a scarf as a string consisting of lowercase English letters only. The pattern for Lagno's scarf is $S$ and Ayon's scarf is $T$. Both strings are of equal length $n$. For a given integer $k$, you can perform the following operation as many times as you want (maybe zero).
- Choose two indices $i$ and $j$ such that $1\leq i,j\leq n$ and $\left|i-j\right|=k$.
- Change $S[i]$ to $S[j]$.
Can Lagno change her string $S$ to make it equal to her brother's string $T$?
Input starts with an integer $T$ ($1\leq T\leq 10^6$), denoting the number of test cases.
Each case contains three lines. The first line contains two integers $n$ ($2 \leq n \leq 10^6$) and $k$ ($0 < k < n$). The following two lines contain Lagno's string $S$ and Ayon's string $T$. It is guaranteed that both strings have a length of $n$. The strings consist of lowercase English letters.
The sum of $n$ over all test cases does not exceed $10^6$.
For each test case, print a single line containing "Yes" (without quotes) if string $S$ can be made equal to $T$ after zero or more operations, and "No" (without quotes) otherwise.
Input
Input starts with an integer $T$ ($1\leq T\leq 10^6$), denoting the number of test cases.
Each case contains three lines. The first line contains two integers $n$ ($2 \leq n \leq 10^6$) and $k$ ($0 < k < n$). The following two lines contain Lagno's string $S$ and Ayon's string $T$. It is guaranteed that both strings have a length of $n$. The strings consist of lowercase English letters.
The sum of $n$ over all test cases does not exceed $10^6$.
Output
For each test case, print a single line containing "Yes" (without quotes) if string $S$ can be made equal to $T$ after zero or more operations, and "No" (without quotes) otherwise.
2
5 2
ebadc
abcbc
12 1
aaabccabbdbb
abaaaabdbbbc
Yes
No
Note
In the first sample, you can perform the following operations:
- $i = 1$ and $j = 3$ to make $S=$ 'abadc'.
- $i = 3$ and $j = 5$ to make $S=$ 'abcdc'.
- $i = 4$ and $j = 2$ to make $S=$ 'abcbc'.