[ABC459D] 相邻不同重排 (Adjacent Distinct String)
Problem Statement
You are given a string consisting of lowercase English letters.
Determine whether it is possible to rearrange the characters of so that no two adjacent characters are the same, and if so, find one such rearrangement.
You are given test cases; solve each.
Input
The input is given from Standard Input in the following format:
$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$
The -th test case is given in the following format:
$S$
Output
Output the answers for the test cases in order, separated by newlines.
For each test case, if it is impossible to rearrange so that no two adjacent characters are the same, output No.
If it is possible, let be such a rearrangement and output in the following format:
Yes
$S'$
If there are multiple valid rearrangements of , any of them will be accepted.
Example
3
aiiw
doodoo
aabbababcacababaaba
Yes
iwai
No
Yes
ababacabababacababa
Note
-
Constraints:
-
-
is a string of length between and , inclusive, consisting of lowercase English letters.
-
The total length of across all test cases is at most .
-
Source: ABC459D