#P14187. [ICPC 2024 Hangzhou R] AUS

[ICPC 2024 Hangzhou R] AUS

题目描述

Pigeland University will host the 2224 Animal Collegiate Programming Contest (ACPC 2224). Unlike previous years, where teams from the host institution were marked as unofficial, Pigeland will send official teams to compete in the contest with three workstations for each team. Nevertheless, Pig-head, the coach of Pigeland University, remains uncertain about his teams' chances of securing gold medals. As a result, he decides to acquire the contest problems in advance from the AUS problem-setting group, using the excuse of needing to upload data to the online judge.

To prevent cheating, AUS attempts to encrypt the problems using a special cipher. Specifically, problems are represented by strings consisting of lowercase English letters. AUS wants to design a cipher function f(x)f(x) that maps lowercase English letters to lowercase English letters. For a problem S=s1s2snS = s_1s_2\ldots s_{n}, the encrypted version of the problem is another string given by F(S)=f(s1)f(s2)f(sn)F(S) = f(s_1)f(s_2)\ldots f(s_{n}). For example, when S=abcabcS = \texttt{abcabc} and f(a)=af(\texttt{a}) = \texttt{a}, f(b)=kf(\texttt{b}) = \texttt{k}, f(c)=af(\texttt{c}) = \texttt{a}, the encrypted version is F(S)=akaakaF(S) = \texttt{akaaka}.

As a member of AUS, your task is to design the cipher function ff. The leader of AUS believes that the function is strong\textit{strong} if and only if there exists at least one problem that can be encrypted into the same encrypted version as another, while not all problems produce the same encrypted output. To validate this, he will give you three problems S1S_1, S2S_2, and S3S_3, and you need to find a cipher function ff such that F(S1)=F(S2)F(S_1) = F(S_2) and F(S1)F(S3)F(S_1) \neq F(S_3). Since AUS has several experienced members, your task is simply to determine whether such a cipher function exists.

输入格式

There are multiple test cases. The first line contains an integer TT (1T1041 \leq T \leq 10^4) indicating the number of test cases. For each test case:

The first line contains a string S1S_1 (1S11031 \leq |S_1| \leq 10^3) consisting of only lowercase English letters.

The second line contains a string S2S_2 (1S21031 \leq |S_2| \leq 10^3) consisting of only lowercase English letters.

The third line contains a string S3S_3 (1S31031 \leq |S_3| \leq 10^3) consisting of only lowercase English letters.

It is guaranteed that the sum of S1+S2+S3|S_1|+|S_2|+|S_3| of all test cases does not exceed 3×1043 \times 10^4.

输出格式

For each test case, if such cipher function exists, output YES\texttt{YES} in one line. Otherwise, output NO\texttt{NO} instead.

4
abab
cdcd
abce
abab
cdcd
abcd
abab
cdcd
abc
x
yz
def
YES
NO
YES
NO

提示

For the first and third sample test cases, one valid cipher function can be $f(\texttt{a}) = f(\texttt{b}) = f(\texttt{c}) = f(\texttt{d}) = \texttt{a}$ and f(e)=bf(\texttt{e}) = \texttt{b}.