C. From S To T

You are given three strings ss, tt and pp consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.

During each operation you choose any character from pp, erase it from pp and insert it into string ss (you may insert this character anywhere you want: in the beginning of ss, in the end or between any two consecutive characters).

For example, if pp is aba, and ss is de, then the following outcomes are possible (the character we erase from pp and insert into ss is highlighted):

  • aba →→ ba, de →→ ade;
  • aba →→ ba, de →→ dae;
  • aba →→ ba, de →→ dea;
  • aba →→ aa, de →→ bde;
  • aba →→ aa, de →→ dbe;
  • aba →→ aa, de →→ deb;
  • aba →→ ab, de →→ ade;
  • aba →→ ab, de →→ dae;
  • aba →→ ab, de →→ dea;

Your goal is to perform several (maybe zero) operations so that ss becomes equal to tt. Please determine whether it is possible.

Note that you have to answer qq independent queries.

Input

The first line contains one integer qq (1≤q≤1001≤q≤100) — the number of queries. Each query is represented by three consecutive lines.

The first line of each query contains the string ss (1≤|s|≤1001≤|s|≤100) consisting of lowercase Latin letters.

The second line of each query contains the string tt (1≤|t|≤1001≤|t|≤100) consisting of lowercase Latin letters.

The third line of each query contains the string pp (1≤|p|≤1001≤|p|≤100) consisting of lowercase Latin letters.

Output

For each query print YES if it is possible to make ss equal to tt, and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

Example

input

4
ab
acxb
cax
a
aaaa
aaabbcc
a
aaaa
aabbcc
ab
baaa
aaaaa

output

YES
YES
NO
NO

题意:三个字符串s t p,能否将p中的字符放入s中,使其成为t

思路:进行两次判断,1.s是t的字串,2.p中的字符可以补全s,使其成为t

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))

int judge(string a,string b)		//判断a是否是b的字串 
{
	int i,j=0;
	for(i=0;i<b.length();i++)
	{
		for(j;j<a.length();j++)
		{
			if(b[i]==a[j])
			{
				j++;
				break;
			}
			else
				break;
		}
	}
	if(j==a.length())
		return 1;
	else
		return 0;
}

int main()
{
	int q,i,j,k,flag;
	string s,t,p;
	cin>>q;
	while(q--)
	{
		flag=1;
		cin>>s>>t>>p;
		if(judge(s,t))
		{
			//cout<<777<<endl;
			map<char,int>m;
			for(i=0;i<t.length();i++)
				m[t[i]]++;
			for(i=0;i<s.length();i++)
				m[s[i]]--;
			for(i=0;i<p.length();i++)
			{
				if(m[p[i]]>0)
					m[p[i]]--;
			}
			for(i=0;i<t.length();i++)
				if(m[t[i]])
				{
					flag=0;
					break;
				}
		}
		else
			flag=0;
		if(flag)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}