#include <bits/stdc++.h>
using namespace std;
int mas[101];
int t, i1;
int sam[200];
int i, j;
int n;
int p;
string s, s1, s2, s3, l;
int main() {
  cin >> t;
  for (i1 = 0; i1 < t; i1++) {
    cin >> s1 >> s >> s2;
    mas[i1] = 1;
    if (s.length() < s1.length()) {
      mas[i1] = 0;
    } else {
      for (i = 90; i < 200; i++) sam[i] = 0;
      for (i = 0; i < s2.length(); i++) {
        sam[int(s2[i])]++;
      }
      i = 0;
      j = 0;
      l = "";
      p = 1;
      while (i < s.length()) {
        if ((j < s1.length()) && (s1[j] == s[i])) {
          l += s[i];
          j++;
        } else {
          if (sam[int(s[i])] <= 0) {
            p = 0;
            break;
          }
          sam[int(s[i])]--;
        }
        i++;
      }
      if ((p == 0) || (l != s1)) {
        mas[i1] = 0;
      }
    }
  }
  for (i = 0; i < t; i++) {
    if (mas[i])
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
}
