#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j, k, x, y, z, p, s;
  cin >> t;
  char a[101], b[101], c[101];
  while (t--) {
    cin >> a >> b >> c;
    x = strlen(a);
    y = strlen(b);
    z = strlen(c);
    if (x > y) {
      cout << "NO\n";
      continue;
    }
    s = 0;
    j = 0;
    for (i = 0; i < y; i++) {
      if (j < x && b[i] == a[j]) {
        s++, j++;
      }
    }
    if (s != x) {
      cout << "NO\n";
      continue;
    }
    int n[123] = {0}, m[123] = {0};
    for (i = 0; i < x; i++) n[a[i]]++;
    for (i = 0; i < z; i++) n[c[i]]++;
    for (i = 0; i < y; i++) m[b[i]]++;
    int f = 0;
    for (i = 97; i < 123; i++) {
      if (n[i] < m[i]) {
        cout << "NO\n";
        f = 1;
        break;
      }
    }
    if (f == 0) cout << "YES\n";
  }
}
