#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 1003, Mod = 1000000007, MAXLog = 20;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9),
      cout << fixed;
  int q;
  cin >> q;
  while (q--) {
    string s, t, p;
    cin >> s >> t >> p;
    int ptr = 0;
    for (int i = 0; i < t.size() && ptr < s.size(); ++i) {
      if (t[i] == s[ptr]) {
        ++ptr;
      }
    }
    if (ptr != s.size()) {
      cout << "NO\n";
      continue;
    }
    vector<int> mp(26, 0);
    for (int i = 0; i < t.size(); ++i) {
      mp[t[i] - 'a']++;
    }
    for (int i = 0; i < s.size(); ++i) {
      mp[s[i] - 'a']--;
    }
    for (int i = 0; i < p.size(); ++i) {
      mp[p[i] - 'a']--;
    }
    bool f = true;
    for (int i = 0; i < 26; ++i) {
      f &= (mp[i] <= 0);
    }
    if (f) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
