#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int r, s = 0, c;
  for (; !isdigit(c = getchar()); s = c)
    ;
  for (r = c ^ 48; isdigit(c = getchar()); (r *= 10) += c ^ 48)
    ;
  return s ^ 45 ? r : -r;
}
const int N = 110;
int T;
void init() {
  int l1, l2, l3;
  char s[N], t[N], p[N];
  map<char, int> mp;
  bool flag = 0;
  mp.clear();
  scanf("%s%s%s", s + 1, t + 1, p + 1);
  l1 = strlen(s + 1), l2 = strlen(t + 1), l3 = strlen(p + 1);
  for (int i = 1; i <= l3; i++) mp[p[i]]++;
  int f = 1;
  for (int i = 1; i <= l2; i++) {
    if (t[i] == s[f])
      f++;
    else {
      if (mp[t[i]])
        mp[t[i]]--;
      else {
        puts("NO");
        return;
      }
    }
  }
  if (f != l1 + 1)
    puts("NO");
  else
    puts("YES");
}
int main() {
  T = read();
  while (T--) {
    init();
  }
  return 0;
}
