#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
	6.计数题要开long long
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
int t, n, k;
string a, b;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> t;
	while (t--) {
		cin >> n >> k;
		cin >> a >> b;
		a = ' ' + a; b = ' ' + b;
		vector<int>a1(29, 0), b1(29, 0);
		for (int i = 1; i <= n; ++i) a1[a[i] - 'a' + 1]++, b1[b[i] - 'a' + 1]++;
		bool res = true;
		for (int i = 1; i <= 26; ++i) {
			if (a1[i] < b1[i]) res = false;
			a1[i] -= b1[i];
			a1[i + 1] = a1[i + 1] + (a1[i] / k) * k;
		}
		if (res) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}