#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int te, len1, len2, len3, i, cnt, j;
  string s, t, p;
  map<char, long long int> m;
  cin >> te;
  while (te--) {
    cnt = 0;
    cin >> s;
    cin >> t;
    cin >> p;
    len1 = s.length();
    len2 = t.length();
    len3 = p.length();
    i = 0;
    j = 0;
    while (i < len1 && j < len2) {
      if (s[i] == t[j]) {
        i++;
        j++;
      } else {
        m[t[j]]++;
        cnt++;
        j++;
      }
    }
    while (j < len2) {
      m[t[j]]++;
      cnt++;
      j++;
    }
    if (len1 + cnt != t.length()) {
      cout << "NO\n";
      m.clear();
      continue;
    } else {
      for (i = 0; i < len3; i++) {
        if (m.find(p[i]) != m.end()) {
          if (m[p[i]] == 1) {
            m.erase(m.find(p[i]));
          } else {
            m[p[i]]--;
          }
        }
      }
      if (m.size() == 0) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    }
    m.clear();
  }
}
