#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        string a, b;
        cin >> a >> b;
        vector<int> count(26, 0);
        for (char c : a) count[c-'a']++;
        for (char c : b) count[c-'a']--;
        int total = 0;
        bool valid = true;
        for (int i : count) {
            total += i;
            if (total < 0) valid = false;
            if (i % k) valid = false;
        }
        if (valid)
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    return 0;
}
