#include <bits/stdc++.h>
using namespace std;
const long mm = 998244353;
const int maxn = 200005;
template <class TYPE>
TYPE gcd(TYPE x, TYPE y) {
  if (y)
    return gcd(y, x % y);
  else
    return x;
}
template <class TYPE>
TYPE lcm(TYPE x, TYPE y) {
  TYPE t = gcd(x, y);
  return t ? (x / t * y) : 0;
}
bool cmp(double a, double b) { return a < b ? true : false; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  for (int kk = 0; kk < q; kk++) {
    string s, t, p;
    int fre[30] = {0}, cnt = 0;
    cin >> s >> t >> p;
    bool c = true;
    for (int i = 0; i < p.length(); i++) fre[p[i] - 97]++;
    for (int i = 0; i < t.length(); i++) {
      if (t[i] == s[cnt] && cnt < s.length())
        cnt++;
      else if (fre[t[i] - 97])
        fre[t[i] - 97]--;
      else {
        c = false;
        break;
      }
    }
    if (cnt != s.length()) c = false;
    if (c)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
