#include<bits/stdc++.h>
#define int long long
#define X first
#define Y second
#define lson (root<<1)
#define rson (root<<1|1)
#define ALL(x) x.begin(),x.end()
#define CLR(x,y) memset(x,y,sizeof(x))
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
int appa[26];
int appb[26];
bool solve()
{
	CLR(appa,0);
    CLR(appb,0);
	int n,k;
	cin>>n>>k;
	string a,b;
	cin>>a>>b;
	for(auto i:a)appa[i-'a']++;
	for(auto i:b)appb[i-'a']++;
	for(int i=0;i<25;i++)
	{
		//cout<<appa[i]<<' '<<appb[i]<<endl;
		if(appa[i]<appb[i])return 0;
		if((appa[i]-appb[i])%k)return 0;
		appa[i+1]+=(appa[i]-appb[i]);
	}
	return 1;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		if(solve())cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}
