#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, i, j, l, f, lt, lp;
  string s = "", t = "", p = "";
  cin >> q;
  while (q--) {
    f = 1;
    int cnt1[27] = {0}, cnt2[27] = {0};
    cin >> s >> t >> p;
    l = s.length();
    lt = t.length();
    lp = p.length();
    j = 0;
    for (i = 0; i < lt && j < l; i++) {
      if (t[i] == s[j]) {
        t[i] = '.';
        j++;
      }
    }
    for (i = 0; i < lt; i++) {
      if (t[i] >= 'a' && t[i] <= 'z') cnt1[t[i] - 'a' + 1]++;
    }
    for (i = 0; i < lp; i++) {
      cnt2[p[i] - 'a' + 1]++;
    }
    if (j != l) {
      f = 0;
    }
    for (i = 1; i <= 26; i++) {
      if (cnt1[i] > cnt2[i]) f = 0;
    }
    if (f)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
