#include <bits/stdc++.h>
using namespace std;
string s1, s2, s3;
long long x[500];
signed main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  while (n--) {
    memset(x, 0, sizeof(x));
    cin >> s1 >> s2 >> s3;
    long long len = s1.size();
    s1 += '*';
    long long i = 0;
    for (auto& a : s2) {
      if (a == s1[i]) {
        i++;
      }
    }
    if (i != len) {
      cout << "NO" << '\n';
      continue;
    }
    for (auto& a : s1) {
      x[a]++;
    }
    for (auto& a : s2) {
      x[a]--;
    }
    for (auto& a : s3) {
      x[a]++;
    }
    bool k = true;
    for (long long i = 'a'; i <= 'z'; i++) {
      if (x[i] < 0) {
        k = false;
      }
    }
    if (k) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
  return 0;
}
