#include <bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define endl '\n'
#define PI acos(-1)
using namespace std;
void fast()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll frea[27], freb[27];
int main()
{
fast();
int tt; cin >> tt;
while (tt--)
{
memset(frea, 0, sizeof frea);
memset(freb, 0, sizeof freb);
bool p = true;
ll n, k; cin >> n >> k;
string a, b; cin >> a >> b;
for (auto i : a)
frea[i - 'a']++;
for (auto i : b)
freb[i - 'a']++;
for (int i = 0; i < 26; i++)
{
ll m = min(frea[i], freb[i]);
frea[i] -= m;
freb[i] -= m;
}
for (int i = 0; i < 26; i++)
{
if (!(freb[i] % k)) {
for (int j = 0; j < i; j++)
{
if (frea[j] >= k)
{
ll m = min(freb[i], frea[j]);
frea[j] -= m;
freb[i] -= m;
}
if (!freb[i])
break;
}
}
else {
p = false;
break;
}
}
for(int i=0;i<26;i++)
if (frea[i] != freb[i])
{
p = false;
break;
}
if (p)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nIAojZGVmaW5lIGFsbCh2KSB2LmJlZ2luKCksdi5lbmQoKQojZGVmaW5lIGVuZGwgJ1xuJwojZGVmaW5lIFBJIGFjb3MoLTEpCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZvaWQgZmFzdCgpCnsKICAgIHN0ZDo6aW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKfQoKbGwgZnJlYVsyN10sIGZyZWJbMjddOwoKaW50IG1haW4oKQp7CiAgICBmYXN0KCk7CiAgICBpbnQgdHQ7IGNpbiA+PiB0dDsKICAgIHdoaWxlICh0dC0tKQogICAgewogICAgICAgIG1lbXNldChmcmVhLCAwLCBzaXplb2YgZnJlYSk7CiAgICAgICAgbWVtc2V0KGZyZWIsIDAsIHNpemVvZiBmcmViKTsKICAgICAgICBib29sIHAgPSB0cnVlOwogICAgICAgIGxsIG4sIGs7IGNpbiA+PiBuID4+IGs7CiAgICAgICAgc3RyaW5nIGEsIGI7IGNpbiA+PiBhID4+IGI7CiAgICAgICAgZm9yIChhdXRvIGkgOiBhKQogICAgICAgICAgICBmcmVhW2kgLSAnYSddKys7CiAgICAgICAgZm9yIChhdXRvIGkgOiBiKQogICAgICAgICAgICBmcmViW2kgLSAnYSddKys7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCAyNjsgaSsrKQogICAgICAgewogICAgICAgICAgICBsbCBtID0gbWluKGZyZWFbaV0sIGZyZWJbaV0pOwogICAgICAgICAgICBmcmVhW2ldIC09IG07CiAgICAgICAgICAgIGZyZWJbaV0gLT0gbTsKICAgICAgICB9CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCAyNjsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKCEoZnJlYltpXSAlIGspKSB7CiAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IGk7IGorKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZnJlYVtqXSA+PSBrKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGwgbSA9IG1pbihmcmViW2ldLCBmcmVhW2pdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnJlYVtqXSAtPSBtOwogICAgICAgICAgICAgICAgICAgICAgICBmcmViW2ldIC09IG07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghZnJlYltpXSkKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBwID0gZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgIAogICAgICAgIGZvcihpbnQgaT0wO2k8MjY7aSsrKQogICAgICAgICAgICBpZiAoZnJlYVtpXSAhPSBmcmViW2ldKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwID0gZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICBpZiAocCkKICAgICAgICAgICAgY291dCA8PCAiWUVTIiA8PCBlbmRsOwogICAgICAgIGVsc2UKICAgICAgICAgICAgY291dCA8PCAiTk8iIDw8IGVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
^
Main.java:2: error: illegal character: '#'
#define ll long long
^
Main.java:3: error: illegal character: '#'
#define all(v) v.begin(),v.end()
^
Main.java:4: error: illegal character: '#'
#define endl '\n'
^
Main.java:5: error: illegal character: '#'
#define PI acos(-1)
^
Main.java:7: error: class, interface, or enum expected
void fast()
^
Main.java:10: error: class, interface, or enum expected
cin.tie(0);
^
Main.java:11: error: class, interface, or enum expected
cout.tie(0);
^
Main.java:12: error: class, interface, or enum expected
}
^
Main.java:16: error: class, interface, or enum expected
int main()
^
Main.java:19: error: class, interface, or enum expected
int tt; cin >> tt;
^
Main.java:19: error: class, interface, or enum expected
int tt; cin >> tt;
^
Main.java:20: error: class, interface, or enum expected
while (tt--)
^
Main.java:23: error: class, interface, or enum expected
memset(freb, 0, sizeof freb);
^
Main.java:24: error: class, interface, or enum expected
bool p = true;
^
Main.java:25: error: class, interface, or enum expected
ll n, k; cin >> n >> k;
^
Main.java:25: error: class, interface, or enum expected
ll n, k; cin >> n >> k;
^
Main.java:26: error: class, interface, or enum expected
string a, b; cin >> a >> b;
^
Main.java:26: error: class, interface, or enum expected
string a, b; cin >> a >> b;
^
Main.java:27: error: class, interface, or enum expected
for (auto i : a)
^
Main.java:29: error: class, interface, or enum expected
for (auto i : b)
^
Main.java:31: error: class, interface, or enum expected
for (int i = 0; i < 26; i++)
^
Main.java:31: error: class, interface, or enum expected
for (int i = 0; i < 26; i++)
^
Main.java:31: error: class, interface, or enum expected
for (int i = 0; i < 26; i++)
^
Main.java:34: error: class, interface, or enum expected
frea[i] -= m;
^
Main.java:35: error: class, interface, or enum expected
freb[i] -= m;
^
Main.java:36: error: class, interface, or enum expected
}
^
Main.java:37: error: class, interface, or enum expected
for (int i = 0; i < 26; i++)
^
Main.java:37: error: class, interface, or enum expected
for (int i = 0; i < 26; i++)
^
Main.java:40: error: class, interface, or enum expected
for (int j = 0; j < i; j++)
^
Main.java:40: error: class, interface, or enum expected
for (int j = 0; j < i; j++)
^
Main.java:45: error: class, interface, or enum expected
frea[j] -= m;
^
Main.java:46: error: class, interface, or enum expected
freb[i] -= m;
^
Main.java:47: error: class, interface, or enum expected
}
^
Main.java:50: error: class, interface, or enum expected
}
^
Main.java:54: error: class, interface, or enum expected
break;
^
Main.java:55: error: class, interface, or enum expected
}
^
Main.java:58: error: class, interface, or enum expected
for(int i=0;i<26;i++)
^
Main.java:58: error: class, interface, or enum expected
for(int i=0;i<26;i++)
^
Main.java:62: error: class, interface, or enum expected
break;
^
Main.java:63: error: class, interface, or enum expected
}
^
Main.java:67: error: class, interface, or enum expected
else
^
Main.java:69: error: class, interface, or enum expected
}
^
Main.java:71: error: class, interface, or enum expected
}
^
45 errors