#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);


signed main(void)
{
    fastio;
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        string a,b;
        int a_val[30] = {0},b_val[30] = {0};
        cin>>a>>b;
        int mx_val = 0;
        for(int i=0;i<n;i++){
            a_val[a[i]-'a']++;
            b_val[b[i]-'a']++;
            mx_val = max(mx_val,b[i]-'a');
        }
        int p = 0;
        int flag = 1;
        for(int i=0;i<=26;i++){
            p+= max(0,a_val[i]-b_val[i]);
            if(a_val[i]+p<b_val[i]){
                //cout<<"3. bruh"<<endl;
                flag = 0;
            } 
            else{
                p-= max(0,b_val[i]-a_val[i]);
            }            
            if(p%k!=0){
                //cout<<"2. bruh"<<endl;
                flag = 0;
            }

            //cout<<"p and flag and mx_val is "<<p<<" "<<flag<<" "<<mx_val<<endl;
        }
        if(flag){
            std::cout << "Yes" << std::endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}
