#include<bits/stdc++.h>
#define ll long long
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
int main()
{
    fast();
    ll t;
    cin>>t;
    while(t--)
    {
        ll k,n;
        cin>>n>>k;
        string str1,str2;
        cin>>str1;
        cin>>str2;
        vector<int> have(26,0);
        vector<int> need(26,0);
        for(ll i=0;i<n;i++)
            have[str1[i]-'a']++;
        for(ll i=0;i<n;i++)
            need[str2[i]-'a']++;
            ll f=0;
        for(ll i=0;i<26;i++)
        {
            if(need[i]>have[i] || (have[i]-=need[i])%k)
            {
                f=1;
                break;
            }
            have[i+1]+=have[i];
        }
        if(f==1)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}