#include <iostream>
#include <cstring>
#include <unordered_map>

using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, k, cnt = 0;
		string a, b;
		unordered_map<char, int> mp1, mp2;
		scanf("%d%d", &n, &k);
		cin >> a >> b;
		for (int i = 0; i < a.size(); i++) 
			mp1[a[i]]++;
		for (int i = 0; i < b.size(); i++) 
			mp2[b[i]]++;
		bool flag = true;
		for (char i = 'a'; i <= 'z'; i++) {
			if (mp1[i] == mp2[i])
				continue;
			if (mp1[i] > mp2[i])
				cnt += (mp1[i] - mp2[i]);
			else {
				int s = mp2[i] - mp1[i];
				if (cnt < s || s % k) {
					flag = false;
					break;
				}
				cnt -= s;
			}
			if (cnt % k) {
				flag = false;
				break;
			} 
		}
		if (flag)
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}
 	 	    	 	 	 		    		 	  	 		