#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t, p;
  int q;
  cin >> q;
  for (int k = 1; k <= q; k++) {
    cin >> s >> t >> p;
    int a[130] = {0}, b[130] = {0}, c[130] = {0};
    int it = 0;
    if (s.size() > t.size()) {
      cout << "NO" << endl;
      goto h1;
    }
    if (s == t && s.size() == t.size()) {
      cout << "YES" << endl;
      goto h1;
    }
    for (int i = 0; i < t.size(); i++) b[int(t[i])]++;
    for (int i = 0; i < p.size(); i++) c[int(p[i])]++;
    for (int i = 0; i < t.size(); i++) {
      if (s[it] == t[i]) {
        it++;
        goto h2;
      }
      if (c[int(t[i])] > 0) {
        c[int(t[i])]--;
        goto h2;
      }
      cout << "NO" << endl;
      goto h1;
    h2:;
    }
    if (it < s.size()) {
      cout << "NO" << endl;
      goto h1;
    }
    cout << "YES" << endl;
  h1:;
  }
  return 0;
}
