/*****************************************************************
    > File Name: c.cpp
    > Author: Uncle_Sugar
    > Mail: uncle_sugar@qq.com
    > Created Time: 2020/12/10 18:09:05
*****************************************************************/
# include <cstdio>
# include <cstring>
# include <cctype>
# include <cmath>
# include <cstdlib>
# include <climits>
# include <iostream>
# include <iomanip>
# include <set>
# include <map>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>
using namespace std;

struct QuickIO{
	QuickIO(){const int SZ = 1<<20;
		setvbuf(stdin ,new char[SZ],_IOFBF,SZ);
		setvbuf(stdout,new char[SZ],_IOFBF,SZ);
	}				//*From programcaicai*//
}QIO;

const int debug = 1;
const int size  = 5000 + 10; 
const int INF = INT_MAX>>1;
typedef long long ll;

int main()
{
	// std::ios::sync_with_stdio(false);cin.tie(0);
	int ncase;
	scanf("%d", &ncase);
	char str[1000000];
	int cnt[2][200];
	while (ncase--){
		memset(cnt, 0, sizeof(cnt));
		int n, k;
		scanf("%d%d", &n, &k);
		for (int i = 0; i < 2; i++){
			scanf("%s", str);
			for (int j = 0; j < n; j++){
				cnt[i][str[j]]++;
			}
		}
		int flag = 1;
		for (int i = 'a'; i <= 'z'; i++){
			if (cnt[0][i] == cnt[1][i])
				continue;
			else if (cnt[0][i] < cnt[1][i]){
				printf("No\n");
				flag = 0;
				break;
			}else if ((cnt[0][i] - cnt[1][i])%k!=0){
				printf("No\n");
				flag = 0;
				break;
			}else {
				cnt[0][i+1] += cnt[0][i] - cnt[1][i];
				cnt[0][i] = cnt[1][i];
			}
		}
		if (flag)
			printf("Yes\n");
		
	}
	return 0;
}





