#include <bits/stdc++.h>
using namespace std;
int numb[26], nump[26];
int main() {
  ios::sync_with_stdio(false);
  int T;
  string a, b, p;
  cin >> T;
  while (T--) {
    cin >> a >> b >> p;
    memset(numb, 0, sizeof(numb));
    memset(nump, 0, sizeof(nump));
    int lena = a.length();
    int lenb = b.length();
    int i = 0, j = 0;
    while (i < lena && j < lenb) {
      if (a[i] == b[j]) {
        i++;
        j++;
      } else {
        numb[b[j] - 'a']++;
        j++;
      }
    }
    if (i < lena) {
      cout << "NO" << endl;
      continue;
    }
    for (; j < lenb; j++) numb[b[j] - 'a']++;
    for (int i = 0; i < p.length(); i++) nump[p[i] - 'a']++;
    int flag = 1;
    for (int i = 0; i < 26; i++) {
      if (nump[i] < numb[i]) {
        flag = 0;
        break;
      }
    }
    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
