#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define ll long long
#define pb push_back
#define Mid ((L+R)/2)
#define pi pair<int,int>
#define pii pair<int,pi>
#define deb(x) cout<<#x<<"="<<x<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int t,n,k;
string a,b;
int f1[30],f2[30];
int main()
{
    go;
    cin>>t;
    while(t--)
    {
        cin>>n>>k>>a>>b;
        for(int i=0;i<=26;i++)
            f1[i]=f2[i]=0;
        for(int i=0;i<n;i++)
            f1[a[i]-'a']++;
        for(int i=0;i<n;i++)
            f2[b[i]-'a']++;
        bool yes=1;
        for(int i=25;i>=0;i--)
        {
            int x=f2[i];
            int y=f1[i];
            if(x<y)
            {
                yes=0;
                break;
            }
            x-=y;
            if(x%k)
            {
                yes=0;
                break;
            }
            for(int j=i-1;j>=0;j--)
            {
                while(x>=k && f1[j]>=k)
                {
                    x-=k;
                    f1[j]-=k;
                }
            }
            yes&=!x;
        }
        puts(yes ? "Yes":"No");
    }
    return 0;
}
