#include <bits/stdc++.h>
using namespace std;
int ss[125], pp[125], tt[125];
string s, p, t;
int main() {
  int test;
  cin >> test;
  while (test--) {
    cin >> s >> t >> p;
    int lns = s.size();
    int lnt = t.size();
    int lnp = p.size();
    if (lns > lnt) {
      cout << "NO" << endl;
      continue;
    }
    int j = 0, i = 0, ck = 0;
    for (i = 0; i < lns; i++) {
      if (j == lnt) break;
      while (s[i] != t[j]) {
        j++;
        if (j == lnt) {
          ck = 1;
          break;
        }
      }
      if (ck == 1) break;
      j++;
    }
    if (i != lns) {
      cout << "NO" << endl;
      continue;
    }
    for (int i = 97; i <= 122; i++) {
      ss[i] = 0;
      tt[i] = 0;
      pp[i] = 0;
    }
    for (int i = 0; i < lns; i++) {
      ss[s[i]]++;
    }
    for (int i = 0; i < lnt; i++) {
      tt[t[i]]++;
    }
    for (int i = 0; i < lnp; i++) {
      pp[p[i]]++;
    }
    ck = 0;
    for (int i = 97; i <= 122; i++) {
      if (tt[i] - ss[i] > pp[i]) {
        cout << "NO" << endl;
        ck = 1;
        break;
      }
    }
    if (ck == 0) {
      cout << "YES" << endl;
    }
  }
  return 0;
}
