#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>

using namespace std;


int main() {

	int t;
	cin >> t;

	const char alphabet[] = {'a', 'b','c','d', 'e','f','g', 'h','i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r', 's','t', 'u', 'v', 'w', 'x','y','z' };

	for (int i = 0; i < t; i++) {


		string a, b;

		int n, k;
		cin >> n>>k;

		cin >> a >> b;

		vector<pair<int, char>>  lsa,lsb;

		sort(a.begin(), a.end());
		sort(b.begin(), b.end());


		int idx = 0;

		for (int j = 0; j < 26; j++) {

			int count = 0;
			while (idx<n && a[idx]==alphabet[j]) {

				count += 1;
				idx += 1;

				if (idx == n) {

					break;

				}


			}

			lsa.push_back(make_pair(count, alphabet[j]));

		}

		idx = 0;

		for (int j = 0; j < 26; j++) {

			int count = 0;
			while (idx < n && b[idx] == alphabet[j]) {

				count += 1;
				idx += 1;

				if (idx == n) {

					break;

				}


			}

			lsb.push_back(make_pair(count, alphabet[j]));

		
		}

		int error = 0;
		
		for (int j = 0; j < 26; j++) {

			if (lsa[j].first % k !=0) {

				lsb[j].first = lsb[j].first - (lsa[j].first % k);
				lsa[j].first -= (lsa[j].first % k);

			}

		}

		int sum = 0;

	
		for (int j = 0; j < 26; j++) {

			sum += lsa[j].first;

			if (lsb[j].first % k == 0 && lsb[j].first <= sum) {

				sum = sum - lsb[j].first;

			}

			else {
			
				error = 1;

			}


		}

		if (error == 0) {

			cout << "Yes" << endl;

		}

		else {

			cout << "No" << endl;

		}

		


	}


}