You are given three strings aa , bb and cc of the same length nn . The strings consist of lowercase English letters only. The ii -th letter of aa is aiai , the ii -th letter of bb is bibi , the ii -th letter of cc is cici .

For every ii (1≤i≤n1≤i≤n ) you must swap (i.e. exchange) cici with either aiai or bibi . So in total you'll perform exactly nn swap operations, each of them either ci↔aici↔ai or ci↔bici↔bi (ii iterates over all integers between 11 and nn , inclusive).

For example, if aa is "code", bb is "true", and cc is "help", you can make cc equal to "crue" taking the 11 -st and the 44 -th letters from aa and the others from bb . In this way aa becomes "hodp" and bb becomes "tele".

Is it possible that after these swaps the string aa becomes exactly the same as the string bb ?

Input

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤1001≤t≤100 )  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a string of lowercase English letters aa .

The second line of each test case contains a string of lowercase English letters bb .

The third line of each test case contains a string of lowercase English letters cc .

It is guaranteed that in each test case these three strings are non-empty and have the same length, which is not exceeding 100100 .

Output

Print tt lines with answers for all test cases. For each test case:

If it is possible to make string aa equal to string bb print "YES" (without quotes), otherwise print "NO" (without quotes).

You can print either lowercase or uppercase letters in the answers.

Example

Input
4
aaa
bbb
ccc
abc
bca
bca
aabb
bbaa
baba
imi
mii
iim
Output
NO
YES
YES
NO
水题。最终目的是要求a和b一样,这样的话,因为ai或者bi其中之一可以与ci交换,所以如果ai==ci,那么拿bi与ci交换,之后可以得到ai==bi;同理bi==ci,可以拿ai与ci交换,遍历一遍看看能不能满足即可。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
char a[];
char b[];
char c[];
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
int i;
int cnt=;
for(i=;i<strlen(a);i++)
{
if(a[i]==c[i]||b[i]==c[i])cnt++;
}
if(cnt==strlen(a))
{
cout<<"YES"<<endl;
continue;
}
cout<<"NO"<<endl;
}
}

Codeforces Round #619 (Div. 2) A. Three Strings的更多相关文章

  1. Codeforces Round #313 (Div. 1) B. Equivalent Strings

    Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...

  2. Codeforces Round #313 (Div. 2) D. Equivalent Strings

    D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...

  3. Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力

    B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...

  4. Codeforces Round #302 (Div. 1) C. Remembering Strings DP

    C. Remembering Strings Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  5. Codeforces Round #302 (Div. 1) C - Remembering Strings 状压dp

    C - Remembering Strings 思路:最关键的一点是字符的个数比串的个数多. 然后就能状压啦. #include<bits/stdc++.h> #define LL lon ...

  6. (原创)Codeforces Round #550 (Div. 3) A Diverse Strings

    A. Diverse Strings time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. Codeforces Round #313 (Div. 2) 560D Equivalent Strings(dos)

    D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  8. Codeforces Round #619 (Div. 2) Ayoub's function

    Ayoub thinks that he is a very smart person, so he created a function f(s)f(s) , where ss is a binar ...

  9. Codeforces Round #619 (Div. 2)

    A. Three Strings 题意:给三个长度相同的非空字符串abc,依次将c中的每个字符和a或者b中对应位置的字符进行交换,交换必须进行,问能否使得ab相同. 思路:对于每一个位置,如果三个字符 ...

随机推荐

  1. Mysql 慢查询之showprofile

    show profiles:返回服务器上最近执行的语句 资源的使用情况. 一.使用准备 Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后. mysql& ...

  2. pwnable.kr-echo1-Writeup

    pwnable.kr - echo1 - writeup 原文链接:https://www.cnblogs.com/WangAoBo/p/pwnable_kr_echo1.html 旧题新做,发现这道 ...

  3. noobSTL-0-开题报告

    noobSTL-0-开题报告 STL介绍 STL是Standard Template Library的简称,中文名标准模板库. STL是一种泛型编程.面向对象编程关注的是编程的数据方面,而泛型编程关注 ...

  4. C++泛型算法总结

    1 accumulate(b,e,T) 累和(基础和为T) 注意T的类型必须和序列中元素类型相同,如double序列后面的T就必须是0.0,如果是0就会把序列中的数当成int进行求和 2 count( ...

  5. php基础扫盲

    .

  6. python测量代码运行时间方法

    Python 社区有句俗语: “python自己带着电池” ,别自己写计时框架. Python3.2具备一个叫做 timeit 的完美计时工具可以测量python代码的运行时间. timeit 模块: ...

  7. 第十七篇 Linux下常用命令汇总

  8. Bugku-web进阶之phpcmsV9(一个靶机而已,别搞破坏。flag在根目录里txt文件里)

    phpcmsV9 一个靶机而已,别搞破坏. flag在根目录里txt文件里 http://123.206.87.240:8001/    

  9. 【visio】故障树分析图

    率属于 商务 故障树是从一个可能的事故开始,自上而下.一层层的寻找顶事件的直接原因和间接原因事件,直到基本原因事件,并用逻辑图把这些事件之间的逻辑关系表达出来. 主要的应用场景:分析复杂问题原因,一个 ...

  10. Nuxt的路由配置以及传参

    Nuxt 路由可以使用a标签进行链接跳转,例如我们创建了一个demo.vue的文件 <p> <a href="/demo">跳转去Demo页面</a& ...