///Bismillahir Rahmanir Rahim
///Author: Tanvir Ahmmad
///CSE,Islamic University,Bangladesh
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<iterator>
#include <functional> ///sort(arr,arr+n,greater<int>()) for decrement of array
/*every external angle sum=360 degree
angle find using polygon hand(n) ((n-2)*180)/n*/
///Floor[Log(b) N] + 1 = the number of digits when any number is represented in base b
using namespace std;
typedef long long ll;
int main()
{
ll tst;
cin>>tst;
while(tst--)
{
map<char,ll>mp;
map<char,ll>::iterator it;
ll pos=0,flag=0;
string s,t,p;
cin>>s>>t>>p;
for(ll i=0; i<p.size(); i++)
{
if(mp.find(p[i])==mp.end())
mp[p[i]]=1;
else
mp[p[i]]++;
}
for(ll i=0; i<t.size(); i++)
{
if(t[i]==s[pos])
pos++;
else
{
if(mp.find(t[i])==mp.end())
flag=1;
else
{
it=mp.find(t[i]);
if(it->second>=1) mp[t[i]]--;
else flag=1;
}
}
}
if(flag==0 && pos==s.size()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
///Alhamdulillah
Problem Link:https://codeforces.com/problemset/problem/1194/C

Comments
Post a Comment