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

void solve()
{
	int n,k,i,c=0;
	cin>>n>>k;
	vector<int>a(30,0),b(30,0);
	string s,t;
	cin>>s;
	cin>>t;
	for(char x:s)
		a[x-'a']++;
	for(char x:t)
		b[x-'a']++;
	
	// for(i=0;i<26;i++)
	// 	cout<<a[i]<<" "<<b[i]<<endl;
	for(i=0;i<26;i++)
	{
		if(a[i]<b[i] || (a[i]-b[i])%k>0)
		{
			cout<<"No";
			return;
		}
		a[i]-=b[i];
		a[i+1]+=a[i];
	}
	cout<<"Yes";
}

int main()
{
	int _;
	cin>>_;
	while(_--)
	{
		solve();
		cout<<endl;
	}
	return 0;
}