#include <bits/stdc++.h>
using namespace std;
long long int MAX = 1000000007;
vector<char> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    vector<char> a, b, c;
    char s[100];
    cin >> s;
    for (long long int q = 0; q < strlen(s); ++q) {
      a.push_back(s[q]);
    }
    char u[100];
    cin >> u;
    for (long long int q = 0; q < strlen(u); ++q) {
      b.push_back(u[q]);
    }
    char v[100];
    cin >> v;
    for (long long int q = 0; q < strlen(v); ++q) {
      c.push_back(v[q]);
    }
    long long int l, m = 0, n, p = 0, q = 0;
    for (l = 0; l < b.size(); ++l) {
      p = 0;
      for (; m < a.size(); ++m) {
        if (b[l] == a[m]) {
          ++m;
          ++p;
          break;
        } else {
          break;
        }
      }
      if (p == 0) {
        long long int o = 0;
        for (n = 0; n < c.size(); ++n) {
          if (c[n] == b[l]) {
            ++o;
            c.erase(c.begin() + n);
            break;
          }
        }
        if (o == 0) {
          ++q;
          break;
        }
      }
      if (q != 0) break;
    }
    if (q == 0 && m == a.size())
      cout << "YES\n";
    else {
      cout << "NO\n";
    }
  }
  return 0;
}
