#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string s, t, p;
    cin >> s >> t >> p;
    if (s.size() > t.size()) {
      cout << "NO" << '\n';
      continue;
    }
    string::iterator sIt = s.begin();
    string::iterator tIt = t.begin();
    while (tIt != t.end()) {
      if (sIt != s.end() && *sIt == *tIt) {
        sIt++;
        tIt++;
      } else {
        string::iterator pIt = find(p.begin(), p.end(), *tIt);
        if (pIt != p.end()) {
          *pIt = '_';
          tIt++;
        } else {
          cout << "NO" << '\n';
          break;
        }
      }
    }
    if (sIt == s.end() && tIt == t.end())
      cout << "YES"
           << "\n";
    else if (tIt == t.end() && sIt != s.end())
      cout << "NO" << '\n';
  }
  return 0;
}
