#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  for (int I = 0; I < t; I++) {
    string s, t, p;
    cin >> s >> t >> p;
    int n = t.length();
    int m = s.length();
    int j = 0;
    int flag = 1;
    vector<int> a(26, 0);
    vector<int> c(26, 0);
    for (int i = 0; i < n; i++) {
      if (j >= m) {
        int x = t[i];
        x -= 97;
        a[x]++;
      } else if (t[i] == s[j]) {
        j++;
      } else {
        int x = t[i];
        x -= 97;
        a[x]++;
      }
    }
    if (j >= m) {
      for (int i = 0; i < p.length(); i++) {
        int x = p[i];
        x -= 97;
        c[x]++;
      }
      for (int i = 0; i < 26; i++) {
        if (c[i] < a[i]) flag = 0;
      }
      flag == 0 ? cout << "NO\n" : cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
