#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
const long long INF = 1e18;
const long long inf = -1e18;
const long long MOD = 1e9 + 7;
const long long base = 1000 * 1000 * 1000;
long long qw, h, us[N], l, use[N], used[N];
string s, t, p;
int main() {
  cin >> qw;
  for (int q = 1; q <= qw; q++) {
    cin >> s >> t >> p;
    h = -1;
    for (int i = 0; i < s.size(); i++) {
      l = 0;
      for (int j = 0; j < t.size(); j++) {
        if (t[j] == s[i] && j > h) {
          h = j;
          us[j] = 1;
          l = 1;
          break;
        }
      }
      if (l == 0) {
        cout << "NO" << endl;
        goto wow;
      }
    }
    for (int j = 0; j < p.size(); j++) {
      use[p[j]]++;
    }
    for (int j = 0; j < t.size(); j++) {
      if (us[j] == 0) {
        used[t[j]]++;
        if (used[t[j]] > use[t[j]]) {
          cout << "NO" << endl;
          goto wow;
        }
      }
    }
    cout << "YES" << endl;
  wow:;
    for (int j = 'a'; j <= 'z'; j++) {
      use[j] = 0;
      used[j] = 0;
    }
    for (int j = 0; j < t.size(); j++) {
      us[j] = 0;
    }
  }
}
