#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string s, t, p;
    cin >> s >> t >> p;
    int freqs[26];
    memset(freqs, 0, sizeof freqs);
    for (int j = 0; j < p.length(); j++) {
      freqs[p[j] - 'a']++;
    }
    bool ok = true;
    int curr = 0;
    int lens = s.length();
    if (lens > t.length()) ok = false;
    for (int j = 0; j < t.length(); j++) {
      if (!ok) break;
      if (s[curr] == t[j])
        curr++;
      else {
        int seek = t[j] - 'a';
        if (freqs[seek] <= 0) {
          ok = false;
          break;
        }
        freqs[seek]--;
        lens++;
        if (lens > t.length()) {
          ok = false;
          break;
        }
      }
    }
    if (ok)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
