#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int k = 0; k < t; k++) {
    string s;
    string t;
    string p;
    cin >> s >> t >> p;
    int a[26] = {0};
    int b[26] = {0};
    int c[26] = {0};
    int j = 0;
    int counter = 0;
    for (int i = 0; i < t.length(); i++) {
      if (t[i] == s[j]) j++;
      if (j == s.length()) break;
    }
    if (j < s.length()) {
      cout << "NO" << endl;
    } else {
      for (int i = 0; i < s.length(); i++) {
        a[s[i] - 'a']++;
      }
      for (int i = 0; i < t.length(); i++) {
        b[t[i] - 'a']++;
      }
      for (int i = 0; i < p.length(); i++) {
        c[p[i] - 'a']++;
      }
      for (int i = 0; i < 26; i++) {
        if (a[i] + c[i] < b[i]) {
          cout << "NO" << endl;
          counter = 0;
          break;
        } else
          counter = 1;
      }
      if (counter == 1) cout << "YES" << endl;
    }
  }
  return 0;
}
