Codeforces Round 990 (Div. 2)
B
Replace Character
Codeforces
900
原题
← AC →
翻译中…

You're given a string $s$ of length $n$, consisting of only lowercase English letters.

翻译中…

You must do the following operation exactly once:

翻译中…
  • Choose any two indices $i$ and $j$ ($1 \le i, j \le n$). You can choose $i = j$.
  • Set $s_i := s_j$.
翻译中…

You need to minimize the number of distinct permutations$^\dagger$ of $s$. Output any string with the smallest number of distinct permutations after performing exactly one operation.

翻译中…

$^\dagger$ A permutation of the string is an arrangement of its characters into any order. For example, "bac" is a permutation of "abc" but "bcc" is not.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains $n$ ($1 \le n \le 10$) — the length of string $s$.

翻译中…

The second line of each test case contains $s$ of length $n$. The string contains only lowercase English letters.

翻译中…

Output

翻译中…

For each test case, output the required $s$ after applying exactly one operation. If there are multiple solutions, print any of them.

翻译中…

Note

翻译中…

In the first test case, we can obtain the following strings in one operation: "abc", "bbc", "cbc", "aac", "acc", "aba", and "abb".

翻译中…

The string "abc" has $6$ distinct permutations: "abc", "acb", "bac", "bca", "cab", and "cba".

翻译中…

The string "cbc" has $3$ distinct permutations: "bcc", "cbc", and "ccb", which is the lowest of all the obtainable strings. In fact, all obtainable strings except "abc" have $3$ permutations, so any of them would be accepted.

翻译中…

样例

Input #1
6
3
abc
4
xyyx
8
alphabet
1
k
10
aabbccddee
6
ttbddq
Output #1
cbc
yyyx
alphaaet
k
eabbccddee
tttddq
InputCopy OutputCopy
题目信息
题号
2047B
时间限制
1 s
内存限制
256 MB
标签
暴力
组合数学
贪心
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。