#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, i;
  cin >> t;
  while (t--) {
    string s, t, p;
    cin >> s >> t >> p;
    if (s.size() > t.size()) {
      cout << "NO" << endl;
      continue;
    }
    long long int q[27] = {0}, r[27] = {0}, c = 0;
    for (i = 0; i < t.size(); i++) {
      if (s[c] == t[i])
        c++;
      else {
        q[t[i] - 'a']++;
      }
    }
    if (c != s.size()) {
      cout << "NO" << endl;
      continue;
    }
    for (i = 0; i < p.size(); i++) r[p[i] - 'a']++;
    long long int f = 0;
    for (i = 0; i < 27; i++) {
      if (r[i] >= q[i])
        continue;
      else {
        f = 1;
        break;
      }
    }
    if (f == 1) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
  }
  return 0;
}
