#include <bits/stdc++.h>
using namespace std;
bool issub(string s, string t) {
  int cur = 0;
  for (char c : s) {
    if (c == t[cur]) cur++;
    if (cur == t.size()) return true;
  }
  return false;
}
int main() {
  int q, i;
  cin >> q;
  while (q--) {
    string s, t, p;
    cin >> s >> t >> p;
    int a[26], flag = 0;
    memset(a, 0, sizeof(a));
    for (char c : s) a[c - 'a']++;
    for (char c : p) a[c - 'a']++;
    for (char c : t) a[c - 'a']--;
    for (i = 0; i < 26; i++) {
      if (a[i] < 0) {
        flag = 1;
      }
    }
    if (flag == 0 && issub(t, s) == true) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
