#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int t, m, n;
char a[120], b[120], c[120];
int num[26];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%s%s%s", a, b, c);
    if (strlen(a) > strlen(b)) {
      puts("NO");
      continue;
    }
    int flag = 1;
    for (int i = 0; c[i]; i++) {
      num[c[i] - 'a']++;
    }
    int j = 0;
    int len = strlen(a);
    int le = strlen(b);
    for (int i = 0; b[i]; i++) {
      if (a[j] == b[i])
        j++;
      else {
        if (num[b[i] - 'a'] && len < le) {
          num[b[i] - 'a']--;
          len++;
        } else {
          flag = 0;
          break;
        }
      }
    }
    if (flag)
      puts("YES");
    else
      puts("NO");
    memset(num, 0, sizeof num);
  }
  return 0;
}
