#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, t, k, n;
  cin >> t;
  while (t--) {
    string a, b, c;
    cin >> a >> b >> c;
    vector<char> x;
    map<char, int> y;
    int flag = 1;
    for (i = 0, j = 0; a[i] != 0; i++, j++) {
      for (; b[j] != 0 && a[i] != b[j]; j++) x.push_back(b[j]);
      if (0 == b[j]) {
        flag = 0;
        break;
      }
    }
    for (; b[j] != 0; j++) x.push_back(b[j]);
    for (i = 0; c[i] != 0; i++) y[c[i]]++;
    for (i = 0; i < x.size(); i++)
      if (y[x[i]] > 0)
        y[x[i]]--;
      else
        flag = 0;
    if (flag == 1)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
