CF1997A.Strong Password

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Strong Password

Monocarp's current password on Codeforces is a string ss, consisting of lowercase Latin letters. Monocarp thinks that his current password is too weak, so he wants to insert exactly one lowercase Latin letter into the password to make it stronger. Monocarp can choose any letter and insert it anywhere, even before the first character or after the last character.

Monocarp thinks that the password's strength is proportional to the time it takes him to type the password. The time it takes to type the password is calculated as follows:

  • the time to type the first character is 22 seconds;
  • for each character other than the first, the time it takes to type it is 11 second if it is the same as the previous character, or 22 seconds otherwise.

For example, the time it takes to type the password abacaba is 1414; the time it takes to type the password a is 22; the time it takes to type the password aaabacc is 1111.

You have to help Monocarp — insert a lowercase Latin letter into his password so that the resulting password takes the maximum possible amount of time to type.

Input

The first line contains one integer tt (1t10001 \le t \le 1000) — the number of test cases.

Each test case consists of one line containing the string ss (1s101 \le |s| \le 10), consisting of lowercase Latin letters.

Output

For each test case, print one line containing the new password — a string which can be obtained from ss by inserting one lowercase Latin letter. The string you print should have the maximum possible required time to type it. If there are multiple answers, print any of them.

Samples

4
a
aaa
abb
password
wa
aada
abcb
pastsword

在线编程 IDE

建议全屏模式获得最佳体验