#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define pl pair<ll, ll>
#define vl vector<ll>
#define mod 1000000007
#define N 100005

int main()
{
    fastIO
    ll t;  cin>>t;
    while(t--)
    {
        ll n, k, c = 0; cin>>n>>k;
        string s1, s2; cin>>s1>>s2;
        ll a[27] = {0}, b[27] = {0};
        for(ll i = 0; i < n; i++) a[s1[i]-'a'] += 1, b[s2[i]-'a'] += 1;
        for(ll i = 0; i < 26; i++)
        {
            ll mn  = min(a[i], b[i]);
            a[i] -= mn;
            b[i] -= mn;
            if(b[i] != 0 || a[i]%k != 0) c = 1;
            else a[i+1] += a[i];
        }
        if(c) cout<<"No\n";
        else cout<<"Yes\n";
    }
    return 0;
}
