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

#define int                             long long
#define ff                              first
#define ss                                  second
#define bb                                begin()
#define ee                                end()
#define float                             double
#define pb                              push_back
#define mp                              make_pair
#define pii                             pair<int,int>
#define vi                              vector<int>
#define mii                                map<int,int>
#define setbits(x)                         __builtin_popcountll(x)
#define zrobits(x)                      __builtin_ctzll(x)
#define mod                             1000000007
#define inf                             1e18
#define ps(x,y)                         fixed<<setprecision(y)<<x
#define    all(v)                            v.begin(),v.end()
#define w(e)                               int e; cin>>e; while(e--)
vector<vector<int>> graph(1000000);
vi visited(10000000, 0);
void im_mortal()
{
	w(e)
	{
		int n, m;
		string a, b;
		cin >> n >> m >> a >> b;

		sort(all(a));
		sort(all(b));

		vi v1(27, 0);
		vi v2(27, 0);
		// cout << a << endl;
		// cout << b << endl;
		for (int i = 0; i < n; i++)
		{
			v1[a[i] - 'a']++;
			v2[b[i] - 'a']++;
		}
		// for (int i = 0; i < 27; i++)
		// {
		// 	cout << v1[i] << " " << v2[i] << endl;
		// }
		int flag = 0;
		for (int i = 0; i < 26; i++)
		{
			if (v1[i] > v2[i] )
			{

				if ((v1[i] - v2[i]) % m != 0 || i == 26 )
				{
					flag = 1;
					cout << "No" << endl;
					break;
				}
				else
				{
					v1[i + 1] += v1[i] - v2[i];
				}
			}
			else if (v1[i] < v2[i])
			{
				flag = 1;
				cout << "No" << endl;
				break;
			}
		}
		if (flag)
			continue;

		cout << "Yes" << endl;
	}

}

signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	im_mortal();
	return 0;
}