#include <bits/stdc++.h>
#include <vector>
#include<string>
#include <numeric>
using namespace std;

#define forr(i,n) for( int i = 0 ; i < n ; i++)
#define forr1(i,n) for( int i = 1 ; i<= n ; i++)
#define pb push_back
 #define int long long int

set<int> s;
vector<bool> visit;
vector<vector<int>> fgroup;
 
void dfs(int node)
{
    visit[node] = true;
    for (auto it : fgroup[node])
    {
        if (!visit[it])
        {
            s.insert(it);
            dfs(it);
        }
    }
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
        int n ;
        cin>>n;
        while(n--)
        {
           int len , k ;
           cin>>len>>k;
           
           string s1,s2;
           cin>>s1>>s2;
           
           vector<int> a(26) ,b(26);
           
           forr(i,len)
           {
              a[s1[i]-'a']++;
              b[s2[i]-'a']++;
           }
           int flag = 0;
           int sum1 = 0 ,sum2 =0 ;
           forr(i,26)
           {
              sum1 += a[i];
              sum2 += b[i];
              if(abs(a[i] - b[i])%k != 0 || sum1 < sum2)
              {
                 flag++;
                 break;
              }
              
           }
           if(flag)cout<<"NO"<<endl;
           else cout<<"YES"<<endl;
           
          
           
        }

}




