#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back 
#define mp make_pair

#define ll long long 
#define ld long double 

#define vi vector <int>
#define vb vector <bool>
#define vc vector <char>
#define vll vector <ll>
#define vs vector <string>

#define pll pair < ll , ll >
#define pld pair < ld , ld >
#define pii pair < int , int >

#define vpld vector < pld >
#define vpii vector < pii >
#define vpll vector < pll >
#define vpci vector <pair <char,int> >

#define vvi vector < vector < int > >
#define vvll vector < vector < ll > >
#define vvld vector < vector < ld > >
#define vvb vector < vector < bool > >
#define vvpii vector < vector < pii > >
//vector<vector<int>> v(n, vector<int>(n));

#define all(v) (v).begin() , (v).end()
#define allrev(v) (v).rbegin() , (v).rend()

#define dist(x1 , y1 , x2 , y2) sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))

const int MOD = 1e9 + 7 ;

bool isprime (ll num) {
    for (ll i = 2 ; i * i <= num ; ++i) {
		if (num % i == 0) return false ;
	}
    return true;
}
 
ll gcd (ll a, ll b) {
    if (b == 0) return a ;
	else return gcd (b , a % b) ;
}
 
ll lcm (ll a, ll b) {
    return ((a / gcd(a , b)) * b) ;
}
 
ll cel (ll x1, ll y1) {
    if ((x1) <= 0) return (x1) / (y1) ;
    return (((x1) / (y1)) + (((x1) % (y1)) != 0)) ;
}

float squareRoot(float n) 
    { 
        float x = n; 
        float y = 1; 
        float e = 0.000001;
        while (x - y > e) { 
            x = (x + y) / 2; 
            y = n / x; 
        } 
        return x; 
    } 
    
void search(string pat, string txt)  
{  
    int M = pat.size();  
    int N = txt.size();  
    int i = 0;  
  
    while (i <= N - M)  
    {  
        int j;
        for (j = 0; j < M; j++)  
            if (txt[i + j] != pat[j])  
                break;  
        if (j == M) 
        {  
            cout << "Pattern found at index " << i << endl;  
            i = i + M;  
        }  
        else if (j == 0)  
            i = i + 1;  
        else
            i = i + j;  
    }  
}  
    
int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 
/*int INT(string s)
{
    return stoi(s);
}*/

int sum_of_digits(long long n) {
	int res = 0;
	while (n > 0) {
		res += n % 10;
		n /= 10;
	}
	return res;
}

void solve (int test_case) {
	int n,k;
	cin>>n>>k;
	string s1,s2;
	cin>>s1>>s2;
	vi v1(26),v2(26);
    for(int i=0;i<n;i++)
    {
        v1[s1[i]-'a']++;
        v2[s2[i]-'a']++;
    }
    bool flag=true;
    int p=0;
    for(int i=0;i<26;i++)
    {
        int c=p+v1[i]-v2[i];
        p=c;
        if(c<0||c%k) {flag=false; break;}
    }
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main() {
	ios_base :: sync_with_stdio (false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int tc = 1 ;
	cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}
