311337: CF1971B. Different String

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:6 Solved:0

Description

B. Different Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a string $s$ consisting of lowercase English letters.

Rearrange the characters of $s$ to form a new string $r$ that is not equal to $s$, or report that it's impossible.

Input

The first line contains a single integer $t$ ($1 \leq t \leq 1000$) — the number of test cases.

The only line of each test case contains a string $s$ of length at most $10$ consisting of lowercase English letters.

Output

For each test case, if no such string $r$ exists as described in the statement, output "NO" (without quotes).

Otherwise, output "YES" (without quotes). Then, output one line — the string $r$, consisting of letters of string $s$.

You can output "YES" and "NO" in any case (for example, strings "yEs", "yes", and "Yes" will be recognized as a positive response).

If multiple answers are possible, you can output any of them.

ExampleInput
8
codeforces
aaaaa
xxxxy
co
d
nutdealer
mwistht
hhhhhhhhhh
Output
YES
forcodesec
NO
YES
xxyxx
YES
oc
NO
YES
undertale
YES
thtsiwm
NO
Note

In the first test case, another possible answer is $\texttt{forcescode}$.

In the second test case, all rearrangements of $\texttt{aaaaa}$ are equal to $\texttt{aaaaa}$.

Output

题目大意:
给你一个由小写英文字母组成的字符串 s。重新排列字符串 s 的字符以形成一个与 s 不相等的新字符串 r,或者报告这是不可能的。

输入数据格式:
第一行包含一个整数 t(1 ≤ t ≤ 1000)——测试用例的数量。
每个测试用例仅包含一行,有一个长度最多为 10 的由小写英文字母组成的字符串 s。

输出数据格式:
对于每个测试用例,如果没有这样的字符串 r 存在,则输出 "NO"(不带引号)。
否则,输出 "YES"(不带引号)。然后输出一行——由字符串 s 的字母组成的字符串 r。
如果存在多个答案,你可以输出其中任何一个。

请注意,"YES" 和 "NO" 的输出大小写不敏感,即 "yEs", "yes", "Yes" 都会被认为是肯定的回答。

示例:
输入:
```
8
codeforces
aaaaa
xxxxy
co
d
nutdealer
mwistht
hhhhhhhhhh
```
输出:
```
YES
forcodesec
NO
YES
xxyxx
YES
oc
NO
YES
undertale
YES
thtsiwm
NO
```
注意:
- 在第一个测试用例中,另一个可能的答案是 `forcescode`。
- 在第二个测试用例中,字符串 `aaaaa` 的所有排列都等于 `aaaaa`。题目大意: 给你一个由小写英文字母组成的字符串 s。重新排列字符串 s 的字符以形成一个与 s 不相等的新字符串 r,或者报告这是不可能的。 输入数据格式: 第一行包含一个整数 t(1 ≤ t ≤ 1000)——测试用例的数量。 每个测试用例仅包含一行,有一个长度最多为 10 的由小写英文字母组成的字符串 s。 输出数据格式: 对于每个测试用例,如果没有这样的字符串 r 存在,则输出 "NO"(不带引号)。 否则,输出 "YES"(不带引号)。然后输出一行——由字符串 s 的字母组成的字符串 r。 如果存在多个答案,你可以输出其中任何一个。 请注意,"YES" 和 "NO" 的输出大小写不敏感,即 "yEs", "yes", "Yes" 都会被认为是肯定的回答。 示例: 输入: ``` 8 codeforces aaaaa xxxxy co d nutdealer mwistht hhhhhhhhhh ``` 输出: ``` YES forcodesec NO YES xxyxx YES oc NO YES undertale YES thtsiwm NO ``` 注意: - 在第一个测试用例中,另一个可能的答案是 `forcescode`。 - 在第二个测试用例中,字符串 `aaaaa` 的所有排列都等于 `aaaaa`。

加入题单

算法标签: