#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>

using namespace std;


int T;
int n, k;
int nums[26], numt[26];

int main() {
    cin >> T;
    while (T--) {
        string s, t;
        int flag = 0;
        memset(nums, 0, sizeof(nums));
        memset(numt, 0, sizeof(numt));
        cin >> n >> k;
        cin >> s >> t;
        for (int i = 0; i < n; i++) {
            nums[s[i] - 'a']++;
            numt[t[i] - 'a']++;
        }
        for (int i = 0; i < 26; i++) {
            if (nums[i] < numt[i]) {
                flag = 1;
                break;
            }
            else if (nums[i] == numt[i]) {
                continue;
            }
            else if ((nums[i] - numt[i]) % k == 0) {
                nums[i + 1] += nums[i] - numt[i];
            }
            else {
                flag = 1;
                break;
            }

        }
        if (flag)
            printf("No\n");
        else
            printf("Yes\n");
    }
}