#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
#include<climits>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fo(i, a, b) for (int i = a; i <= b; i++)
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define pr(x) printf("%d", x)
#define prl(x) printf("%lld", x)
#define prs() printf(" ")
#define prn() printf("\n")
#define pii pair<int, int> 
#define mp make_pair
const double eps = 1e-8;
const int mod = 998244353;
const int N = 7 + 2e6;

char a[N], b[N];
int numa[30], numb[30];
int main() {
	int t;
	int n, k;
	sc(t);
	while(t--) {
		sc(n), sc(k);
		scanf("%s", a + 1);
		scanf("%s", b + 1);
		memset(numa, 0, sizeof(numa));
		memset(numb, 0, sizeof(numb));
		for (int i = 1; i <= n; i++)
			numa[a[i] - 'a']++, numb[b[i] - 'a']++;
		int flag = 1;
		for (int i = 0; i <= 25; i++) {
			if(numa[i] < numb[i]) {
				flag = 0;
				break;
			}
			else {
				if((numa[i] - numb[i]) % k != 0) {
					flag = 0;
					break;
				}
				numa[i + 1] += numa[i] - numb[i];
			}
		}
		if(flag) printf("Yes\n");
		else printf("No\n");

	}







	return 0;
}