#include <iostream>
#include <string>
using namespace std;
bool is_subsequence(string s, string t)
{
char tmp;
bool is_sub = true;
for (int i = 0; s.size(); i++) {
tmp = s[0];
if (t.find_first_of(tmp, i) == string::npos) {
is_sub = false;
}
s.erase(0, 1);
}
if (is_sub)
return true;
else
return false;
}
int f(string str, char c)
{
int ans = 0;
for (int i = 0; i < str.size(); i++) {
if (str[i]==c) {
ans++;
}
}
return ans;
}
int main()
{
int tt;
cin >> tt;
while (tt--) {
string s, t, p;
cin >> s >> t >> p;
if (!is_subsequence(s, t)) {
cout << "NO" << endl;
continue;
}
bool b = true;
for (int i = 0; i < t.size(); i++) {
if (f(t, t[i]) > f(s, t[i]) + f(p, t[i])) {
b = false;
}
}
if (b) {
cout << "YES" << endl;
}
else
cout << "NO" << endl;
}
return 0;
if (is_sub)
return true;
else
return false;