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. SpringMVC入门和常用注解

    SpringMVC的基本概念 关于 三层架构和 和 MVC 三层架构 我们的开发架构一般都是基于两种形式,一种是 C/S 架构,也就是客户端/服务器,另一种是 B/S 架构,也就 是浏览器服务器.在 ...

  2. 100% 展示 MySQL 语句执行的神器-Optimizer Trace

    在上一篇文章<用Explain 命令分析 MySQL 的 SQL 执行>中,我们讲解了 Explain 命令的详细使用.但是它只能展示 SQL 语句的执行计划,无法展示为什么一些其他的执行 ...

  3. 文档写作利器:Markdown

    大佬的文章,写的很好,里面推荐的Markdown编辑工具很不错,值的推荐. 文档写作利器:Markdown_网络_xcbeyond|疯狂源自梦想,技术成就辉煌-CSDN博客https://blog.c ...

  4. asp.netcore3.1 将服务器配置为需要证书

    运行 asp.netcore 3.1应用程序时,弹出证书选择框. 将服务器配置为需要证书(Kestrel),在Program.cs中,按如下所示配置 Kestrel: public static vo ...

  5. 检查型异常和非检查型异常——Java

    文章目录 检查型异常和非检查型异常--Java 检查型异常 非检查型异常 结语 检查型异常和非检查型异常--Java Java语言规范将派生于Error类或RuntimeExceprion类的所有异常 ...

  6. c++排序二叉树的出现的私有函数讨论,以及二叉树的删除操作详解

    c++排序二叉树的出现的私有函数讨论, 以及二叉树的删除操作详解 标签(空格分隔): c++ 前言 我在c++学习的过程中, 最近打了一个排序二叉树的题目,题目中出现了私有函数成员,当时没有理解清楚这 ...

  7. SpringMVC4——视图、视图解析器、国际化

    视图.视图解析器.国际化 视图的顶级接口:View 视图解析器:ViewResolver   常见的视图和解析器: InternalResourceView.InternalResourceViewR ...

  8. 计算机网络要点---Http

    计算机网络要点---Http 1.工作流程 一次HTTP操作称为一个事务,其工作过程可分为四步: 首先客户机与服务器需要建立 TCP 连接.只要单击某个超级链接,HTTP的工作开始. 建立连接后,客户 ...

  9. 41.4 Method Security方法安全性

    41.4.1 <global-method-security> 这个元素是为Spring Security beans上的安全方法添加支持的主要手段.可以通过使用注释(在接口或类级别定义) ...

  10. 详解Python Graphql

    前言 很高兴现在接手的项目让我接触到了Python Graphql,百度上对其介绍相对较少也不够全面,几乎没有完整的中文文档,所以这边也借此机会学习一下Graphql. 什么是Graphql呢? Gr ...