题目描述
Problem Description
There are two strings of magnets, $a$ and $b$, which can be considered as composed of lowercase or uppercase letters or digits.
You can perform infinite operations on magnet $a$. Each operation can be one of the following two:
- Delete the first several characters, for example, after deleting the first 3 characters of $\texttt{91987}$, the string will become $\texttt{87}$.
- Move the last several characters to the front, for example, after moving the last 3 characters of $\texttt{91987}$ to the front, the string will become $\texttt{98791}$.
The question is whether, after performing operations, magnet $a$ can be made equal to magnet $b$. $a$ and $b$ are considered equal if and only if they have the same length and each character is identical.
To prevent the occurrence of "不可以,总司令" (it's not possible, commander), you need to answer multiple times.
Input Format
The first line contains the number of test cases, $t$.
The next $t$ pairs of lines each contain two strings, representing the magnet strings $a$ and $b$.
Output Format
Output $t$ lines, each containing Y or N to indicate whether it is possible or not to make $a$ equal to $b$ after operations.
Sample Input and Output
Sample Input #1
1
12341234
1234
Sample Output #1
Y
Sample Input #2
1
6012739810910020338452
12345678
Sample Output #2
Y
Sample Input #3
1
123456789
465
Sample Output #3
N
Sample Input #4
See the attached file magnets4.in
Sample Output #4
See the attached file magnets4.ans
Notes/Hints
[Sample Explanation #1]
$$ \texttt{12341234}\\ \to \texttt{1234}\\ = \texttt{1234} $$
[Sample Explanation #2]
$$ \texttt{6012739810910020338452}\\ \to \texttt{2601273981091002033845}\\ \to \texttt{601273981091002033845}\\ \to \texttt{384560127398109100203}\\ \to \texttt{4560127398109100203}\\ \to \texttt{0345601273981091002}\\ \to \texttt{345601273981091002}\\ \to \texttt{091002345601273981}\\ \to \texttt{2345601273981}\\ \to \texttt{3981234560127}\\ \to \texttt{81234560127}\\ \to \texttt{01278123456}\\ \to \texttt{78123456}\\ \to \texttt{12345678} \\ =\texttt{12345678} $$
[Data Range]
Let $\left| a \right|$ denote the length of magnet $a$ in each test case, and $\left| b \right|$ denote the length of magnet $b$ in each test case.
For $20\%$ of the data, it is guaranteed that $\left| a \right| = 1$.
For another $20\%$ of the data, it is guaranteed that $\left| b \right| = 1$.
For $100\%$ of the data, it is guaranteed that $1 \leq \left| a \right|, \left| b \right| \leq 1000$ and $1 \leq t \leq 10$.
It is guaranteed that $a$ and $b$ are non-empty and contain only uppercase and lowercase letters or digits.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分