#include<bits/stdc++.h>
//#define F first
//#define S second
using namespace std;
typedef long long ll;

int main()
{  
     ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    ll t;
    cin>>t;
    while(t--)
    {
        ll i,j,n,k,f=1;
        cin>>n>>k;
       string a,b;
       cin>>a>>b;
       vector<ll>v1(26),v2(26);
       for(i=0;i<a.size();i++)
       {
           v1[a[i]-'a']++;
           v2[b[i]-'a']++;
       }
       for(i=0;i<26;i++)
       {
         if(v1[i]>v2[i])
          {
              if(i+1>=26)
              continue;
              ll x=v1[i]-v2[i];
              v1[i]=v1[i]-(x/k)*k;
              v1[i+1]=v1[i+1]+(x/k)*k;
          }
       }
       for(i=0;i<26;i++)
       {
           if(v1[i]!=v2[i])
           {
               f=0;
               break;
           }
       }
     
       if(f)
       cout<<"YES\n";
       else
       cout<<"NO\n";
       
    }
    
    return 0;
}