#include <bits/stdc++.h>
using namespace std;
#define all(nums) nums.begin(), nums.end()
#define allr(nums) nums.rbegin(), nums.rend()
#define len(a) int((a).size())
typedef long long int ll;
const ll imax = INT64_MAX;
const ll imin = INT64_MIN;
typedef vector<vector<int>> graph;
graph g;
template<class T>T cal(T n) {return (n*1ll*(n-1))/2;}
template<class T>T mx(T begin, T end){return max_element(begin, end);}
template<class T>T mn(T begin, T end){return min_element(begin, end);}
template<class T>void getUnique(vector<T>& nums){sort(nums.begin(), nums.end()); nums.erase(unique(nums.begin(), nums.end()), nums.end());}
template<class T>void print(vector<T>nums){for(T i:nums)cout<<i<<" ";cout<<"\n";}
template<class T>void read(vector<T>&nums){for(T& i:nums)cin>>i;}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t = 1;
    cin>>t;
    while(t--) {
        int n, k;
        cin>>n>>k;
        string s, t;
        cin>>s>>t;
        vector<int>a(26), b(26);
        for (char ch: s)    a[ch-'a']++;
        for (char ch: t)    b[ch-'a']++;
        
        for (int i=0; i<26; ++i) {
            if (a[i] == b[i])   continue ;

            for (int j=i-1; j>=0; --j) {
                while (a[i] < b[i] && a[j]-k >= b[j]) {
                    a[i] += k;
                    a[j] -= k;
                }
            }
        } 
    // 4 2
    // abba
    // azza
        cout << (a == b?"Yes":"No")<<"\n";
    }
    return 0;   
}