#include <bits/stdc++.h>
using namespace std;
int cnt[26];
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() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s, t, p;
    cin >> s >> t >> p;
    memset(cnt, 0, sizeof cnt);
    for (char c : s) cnt[c - 'a']++;
    for (char c : t) cnt[c - 'a']--;
    for (char c : p) cnt[c - 'a']++;
    bool good = true;
    for (int i = 0; i < 26; i++)
      if (cnt[i] < 0) good = false;
    if (good && issub(t, s))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
