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

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

Copy
YES
YES
NO
NO
Note

In the first test case there is the following sequence of operation:

  1. s=s= ab, t=t= acxb, p=p= cax;
  2. s=s= acb, t=t= acxb, p=p= ax;
  3. s=s= acxb, t=t= acxb, p=p= a.

In the second test case there is the following sequence of operation:

  1. s=s= a, t=t= aaaa, p=p= aaabbcc;
  2. s=s= aa, t=t= aaaa, p=p= aabbcc;
  3. s=s= aaa, t=t= aaaa, p=p= abbcc;
  4. s=s= aaaa, t=t= aaaa, p=p= bbcc.

代码:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
string s,t,p;
int vis[maxn];
 
int dp[][];
string str;
int main()
{ int T;
cin>>T;
while(T--)
{
cin>>s>>t>>p;
str=s+p;
memset(vis,,sizeof(vis));
int len1=t.length();
int len2=str.length();
int len3=s.length();
int ans=;
memset(dp,,sizeof(dp));
for(int i=;i<=len1;i++)
{
for(int j=;j<=len3;j++)
{
if(t[i-]==s[j-])
{
dp[i][j]=max(dp[i][j],dp[i-][j-]+);
}
else
{
dp[i][j]=max(dp[i-][j],dp[i][j-]);
}
}
}
int flag=;
if(dp[len1][len3]==len3)
{
flag=;
}
if(flag==)
{
puts("NO");
continue;
}
else
{
for(int i=;i<len1;i++)
{
for(int j=;j<len2;j++)
{
if(str[j]==t[i]&&vis[j]==)
{
vis[j]=;
ans++;
break;
}
}
}
if(ans==len1)
{
puts("YES");
}
else
{
puts("NO");
}
} }
return ;
}

最新文章

  1. js数组方法
  2. SqlServer类库(自定义)
  3. 【Java】:googleSearch
  4. SVN Access to ‘/svn/Test/!svn/me’ forbidden,不能更新解决办法
  5. Yii框架,在页面输出执行sql语句,方便调试
  6. MSSQL 2005数据库可疑状态
  7. The J1850 Core
  8. C# Byte[]数组读取和写入文件
  9. php脚本生成google play url的下载链接,下载apk并自动反编译后获取android版本号
  10. iis无法加载样式
  11. URL中文参数乱码的一个解决办法
  12. 《重构&mdash;&mdash;改善既有代码的设计》【PDF】下载
  13. 如何使用JPQL写纯SQL语句
  14. Wpf 之Canvas介绍
  15. day28 网络编程
  16. Nginx反向代理+Tomcat+Springmvc获取用户访问ip
  17. 轻松转移github项目步骤
  18. C#语法之匿名函数和Lambda表达式
  19. MySQL的异步复制、全同步复制与半同步复制
  20. 【Visual Studio】报错SignTool Error: No certificates were found that met all the given criteria.

热门文章

  1. Ubuntu环境下使用Jupyter Notebook查找桌面.csv文档的方法
  2. 系统UISearchController详解
  3. Chrome自动格式化Json输出
  4. Docker-compose实战
  5. Django Web 测试
  6. 怎么将PPT文件上传到微信公众号上?
  7. 【Python笔记】2020年7月30日练习【汉诺塔游戏】
  8. C#LeetCode刷题之#387-字符串中的第一个唯一字符(First Unique Character in a String)
  9. flask-sqlalchemy同字段多条件过滤
  10. flask_restful 的reqparse获取验证前端参数