
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define all(x) (x).begin(),(x).end()





signed main()
{
	ll t;	
	cin>>t;
	while(t--)
	{
		ll n,k;
		cin>>n>>k;
		
		string a,b;
		cin>>a>>b;
		vector <int> freq1(27,0),freq2(27,0);
		
	

		
			for(auto x:a)
				freq1[x-'a']++;
			for(auto x:b)
				freq2[x-'a']++;
			
			bool ok=false;

			for(int i=0;i<26;i++)
			{
				
				
			
				if(i!=25 && freq1[i]>freq2[i])
				{
					ll diff=(freq1[i]-freq2[i]);

					if(diff%k!=0)
					{
						ok=true;
					}
					else
					{
						freq1[i+1]+=freq1[i]-freq2[i];
						freq1[i]=freq2[i];
					
					}
				
				}
				else if(freq1[i]<freq2[i])
					ok=true;
			
			}

			(ok)?cout<<"No":cout<<"Yes";
			cout<<'\n';			

		
	}	


}

