//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
#define UPADHYAY int t;cin>>t;while(t--)
int main(){
    NIMISH
    UPADHYAY{
        ll n,ans=0,k,j,due=0;
        cin>>n>>k;
        string a,b;
        cin>>a>>b;
        ll c[26]={0},c1[26]={0},i;
        for(i=0;i<n;i++){
            j=a[i]-'a';
            c[j]++;
            j=b[i]-'a';
            c1[j]++;
        }
        for(i=0;i<26;i++){
            j=c[i]-c1[i]+due;
            if(j<0)
            ans=1;
            else if(j%k!=0)
            ans=1;
            due=j;
        }
        if(ans==1)
        cout<<"No"<<"\n";
        else
        cout<<"Yes"<<"\n";
    }
}