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 ;
}

Educational Codeforces Round 68 (Rated for Div. 2)-C-From S To T的更多相关文章

  1. Educational Codeforces Round 68 (Rated for Div. 2)---B

    http://codeforces.com/contest/1194/problem/B /* */ # include <bits/stdc++.h> using namespace s ...

  2. Educational Codeforces Round 68 (Rated for Div. 2)补题

    A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; ...

  3. Educational Codeforces Round 68 (Rated for Div. 2) C. From S To T (字符串处理)

    C. From S To T time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...

  4. Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)

    D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...

  5. Educational Codeforces Round 68 (Rated for Div. 2)D(SG函数打表,找规律)

    #include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while ...

  6. Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game

    output standard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  8. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  9. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

随机推荐

  1. 一个C++版本的Sqlite3封装--SmartDb

    Sqlite是一个非常轻量级的开源数据库,在嵌入式系统中使用的比较多,存储管理数据非常方便,Sqlite库提供的基于C语言的API,用起来也挺简单,但是有一点不太好的就是API使用起来有些繁琐,另外就 ...

  2. CI4框架应用五 - 加载视图

    这节我们来看一下CI4框架中视图的加载, CI4中提供了几种方式加载视图. 1. 利用CI4框架提供的全局函数view(‘模板名’),如果需要传参数可以在第二个参数传一个数组 我们先修改一下之前定义的 ...

  3. Kubernetes 使用arthas进行调试

    环境 因为k8s中是最基本的jre,网上说缺少tools.jar,但是补充了以后还是不行,最后还是将整个jdk给移到容器中的. jre中执行: /home # /opt/jre/bin/java -j ...

  4. java 多态二

    一 多态-转型 多态的转型分为向上转型与向下转型两种: 向上转型:当有子类对象赋值给一个父类引用时,便是向上转型,多态本身就是向上转型的过程. 使用格式: 父类类型  变量名 = new 子类类型() ...

  5. ReentrantLock与synchronized 源码解析

    一.概念及执行原理   在 JDK 1.5 之前共享对象的协调机制只有 synchronized 和 volatile,在 JDK 1.5 中增加了新的机制 ReentrantLock,该机制的诞生并 ...

  6. 分析现有 WPF / Windows Forms 程序能否顺利迁移到 .NET Core 3.0

    本文转自 https://blog.csdn.net/WPwalter/article/details/82859449 使用 .NET Core 3.0 Desktop API Analyzer 分 ...

  7. Vue Element-UI 中列表单选的实现

    el-table中单选的实现 引用场景: 选择单条数据进行业务操作 实现方式: 给el-table-column设置el-radio Template 代码 <div class="r ...

  8. The Definitive Guide to Ruby's C API The Ruby C API Running Ruby in C Running C in Ruby

    最近在研究如何在C/C++中 嵌入ruby脚本,很感谢找到了一篇文章,分享一下. The Definitive Guide to Ruby's C API

  9. 存储系列之 共享文件:链接link

    一.link与unlink的定义 1.link link是Linux文件系统目录管理的一个系统调用,创建一个链接,该链接只是创建一个目录项,上文ext2的介绍中提到过目录项是<文件名,inode ...

  10. MySQL字符集操作

    一.查看编码 show variables like 'character%'; 二.临时设置编码 1.set names xxx set names ${编码}; "set names x ...