#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, j, x, y, q;
  cin >> q;
  while (q--) {
    string s, t, p;
    cin >> s >> t >> p;
    int l1 = s.length(), l2 = t.length(), l3 = p.length();
    if (l1 > l2) {
      cout << "NO\n";
      continue;
    }
    int a[27] = {0};
    for (i = 0; i < l3; ++i) {
      a[p[i] - 'a']++;
    }
    j = 0;
    int flag = 0;
    for (i = 0; i < l2; ++i) {
      if (j < l1) {
        if (t[i] == s[j]) {
          ++j;
          continue;
        }
        if (a[t[i] - 'a'] > 0) {
          a[t[i] - 'a']--;
        } else {
          flag = 1;
          break;
        }
      } else {
        if (a[t[i] - 'a'] > 0) {
          a[t[i] - 'a']--;
        } else {
          flag = 1;
          break;
        }
      }
    }
    if (j != l1) {
      flag = 1;
    }
    if (flag) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
    }
  }
  return 0;
}
