#include <bits/stdc++.h>
using namespace std;
string s, t, p;
int cnt1[26], cnt2[26], cnt3[26];
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> s >> t >> p;
    bool flag = true;
    for (int i = 0; i < 26; ++i) cnt1[i] = cnt2[i] = cnt3[i] = 0;
    int len1 = s.size(), len2 = t.size(), len3 = p.size();
    for (int i = 0; i < len1; i++) cnt1[s[i] - 'a']++;
    for (int i = 0; i < len2; i++) cnt2[t[i] - 'a']++;
    for (int i = 0; i < len3; i++) cnt3[p[i] - 'a']++;
    for (int i = 0; i < 26; ++i) {
      if (cnt2[i] > cnt1[i] + cnt3[i]) {
        flag = false;
        break;
      }
    }
    if (flag == true) {
      int i, j;
      for (i = 0, j = 0; i < len2;) {
        if (s[j] == t[i]) {
          i++;
          j++;
        } else {
          int k = t[i] - 'a';
          if (cnt3[k]) {
            cnt3[k]--;
            i++;
          } else {
            flag = false;
            break;
          }
        }
        if (j == len1) {
          for (; i < len2; i++) {
            int k = t[i] - 'a';
            if (cnt3[k])
              cnt3[k]--;
            else {
              flag = false;
              break;
            }
          }
        }
        if (flag == false) break;
      }
      if (j < len1) flag = false;
      if (flag)
        printf("YES\n");
      else
        printf("NO\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
