#include <bits/stdc++.h>
using namespace std;
int pc[27];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    memset(pc, 0, sizeof(pc));
    string s;
    string t;
    string p;
    bool ans = 1;
    cin >> s >> t >> p;
    for (int i = 0; i < p.size(); i++) pc[p[i] - 'a']++;
    string tempt = t;
    int k = 0;
    for (int i = 0; i < tempt.size();) {
      if (k < s.size() && tempt[i] == s[k]) {
        k++;
        tempt.erase(i, 1);
      } else if (pc[tempt[i] - 'a'] == 0) {
        ans = 0;
        break;
      } else {
        pc[tempt[i] - 'a']--;
        i++;
      }
    }
    if (k != s.size()) ans = 0;
    if (ans)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
