#pragma GCC optimize(3,"Ofast","inline")
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
const int maxn = 1e6 + 10;
const ll mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int t;
int n, k;
string s1, s2;
int cnt[27];

void solve()
{
  int f = 0;
  memset(cnt, 0, sizeof(cnt));
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  if(s1 == s2)  puts("Yes");
  else{
    for(int i = 0; i < n; i ++) cnt[s1[i] - 'a'] ++;
    for(int i = 0; i < n; i ++) cnt[s2[i] - 'a'] --;
    for(int i = 0; i < 26; i ++){
      if(cnt[i] < 0 || cnt[i] % k){
          f = 1;
          break;
        }
      cnt[i + 1] += cnt[i];
    }
    puts(!f ? "Yes" : "No");
  }
}

int main(){
  std::ios::sync_with_stdio(false);
  cin >> t;
  while(t --){
    cin >> n >> k;
    cin >> s1 >> s2;
    solve();
  }
  return 0;
}
