#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include <sstream>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<vector>
#define INF 0x7FFFFFFFFFFFFFFFLL
#define inf 1000000000
using namespace std;
typedef long long ll;
const int mod=1e8+7;
const int N=1e6+10;
char s[N];
char ss[N];
int vis[30];
int viss[30];
int main()
{
    int num;
    scanf("%d",&num);
    int n,m;
    while(num--)
    {
        memset(vis,0,sizeof(vis));
        memset(viss,0,sizeof(viss));
        scanf("%d%d%s%s",&n,&m,s,ss);
        for(int i=0;i<n;i++)
        {
            vis[s[i]-'a']++;
            viss[ss[i]-'a']++;
        }
        int sum=0;
        bool flag=0;
        for(int i=0;i<26;i++)
        {
            sum+=vis[i];
            if(sum<viss[i])
            {

                flag=1;
                break;
            }
            sum-=viss[i];
            if(sum%m)
            {
                flag=1;
                break;
            }
        }
        if(flag)
        {
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
        }
    }
    return 0;
}
