#include <bits/stdc++.h>
namespace {
    typedef long long T; 
    const int maxN = 100 + 5;

    int n, k;
    std::string a, b;
    int cnta[maxN], cntb[maxN];

    void Solve() {
        std::cin >> n >> k >> a >> b;
        memset(cnta, 0, sizeof cnta), memset(cntb, 0, sizeof cntb);
        for(int i = 0; i < n; i++)
            cnta[a[i] - 'a']++, cntb[b[i] - 'a']++;
        int usable = 0;
        for(int i = 0; i <= 'z' - 'a'; i++) {
            if(cnta[i] == cntb[i])
                continue;
            if(cnta[i] > cntb[i]) {
                if((cnta[i] - cntb[i]) % k) {
                    std::cout << "No" << std::endl;
                    return;
                }
                else
                    usable += cnta[i] - cntb[i];
            } 
            if(cnta[i] < cntb[i]) {
                if((cntb[i] - cnta[i]) % k) {
                    std::cout << "No" << std::endl;
                    return;
                }
                else if(usable < cntb[i] - cnta[i]) {
                    std::cout << "No" << std::endl;
                    return;
                }
                else 
                    usable -= cntb[i] - cnta[i];
            }
        }
        std::cout << (usable ? "No" : "Yes") << std::endl;
    }
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    int t(1); std::cin >> t;
    for(int i = 1; i <= t; i++) Solve();
    std::cout << std::flush;
    return 0;
}
 			 	 	       	   		  	  		  	