#include <bits/stdc++.h>
using namespace std;
int tt, n, m;
map<char, int> mp;
char p[150];
char s[150];
char t[150];
int main() {
  cin >> tt;
  while (tt--) {
    mp.clear();
    scanf("%s %s %s", s, t, p);
    int s1 = strlen(p);
    for (int i = 0; i < s1; ++i) {
      mp[p[i]]++;
    }
    int s2 = strlen(s), s3 = strlen(t);
    if (s2 > s3) {
      printf("NO\n");
      continue;
    }
    int k = 0, d = 1;
    for (int i = 0; i < s3; ++i) {
      if (k < s2 && s[k] != t[i]) {
        if (mp[t[i]]) {
          mp[t[i]]--;
        } else if (mp[t[i]] == 0) {
          printf("NO\n");
          d = 0;
          break;
        }
      } else if (k == s2) {
        if (mp[t[i]]) {
          mp[t[i]]--;
        } else if (mp[t[i]] == 0) {
          printf("NO\n");
          d = 0;
          break;
        }
      } else
        k++;
    }
    if (k != s2 && d == 1) {
      printf("NO\n");
      continue;
    }
    if (d == 1) {
      printf("YES\n");
    }
  }
  return 0;
}
