luogu#P16600. [SYSUCPC 2025] Perfect Life
[SYSUCPC 2025] Perfect Life
Problem Description
wants to live a perfect life. In the future, he acquires a time machine that gives him a chance to alter his life. His life is represented by a string . He can modify the string using another string .
Each modification allows him to choose a positive integer in the range and replace the substring with . More precisely, for each , he sets . This operation can be performed infinitely many times. considers his life perfect if and only if ---that is, when the string becomes a palindrome.
wants to know whether it's possible for his life to become perfect through these modifications.
There are test cases. For each test case, you are given two strings and .If can become a palindrome, output . Otherwise, output .
Input Format
The first line contains an integer means that there are test cases.
The next lines each contain strings .
It is guaranteed that and contain only uppercase and lowercase letters, and the total length of all strings across test cases does not exceed .
Output Format
The next lines each contain or .
9
asdppsaAA Aad
pjdaAjcKaA Aad
pjdsdAadaA Aad
pjdjAjcKsA Aad
ABAB AB
BBA AB
abcdDea cd
abcdDea cb
asbAADbbaaa abbc
Yes
Yes
Yes
No
No
Yes
No
Yes
Yes
Hint
In the first test case, can be turned into a palindrome through 3 modifications. By sequentially choosing , is changed as follows: $S \to \text{AadppsaAA}\to \text{AadAadaAA}\to \text{AAadadaAA}$.
In the fourth test case,there is no way to change.