CF2047B.Replace Character

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

Replace Character

You're given a string ss of length nn, consisting of only lowercase English letters.

You must do the following operation exactly once:

  • Choose any two indices ii and jj (1i,jn1 \le i, j \le n). You can choose i=ji = j.
  • Set si:=sjs_i := s_j.

You need to minimize the number of distinct permutations^\dagger of ss. 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 tt (1t5001 \le t \le 500). The description of the test cases follows.

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

The second line of each test case contains ss of length nn. The string contains only lowercase English letters.

Output

For each test case, output the required ss 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 66 distinct permutations: "abc", "acb", "bac", "bca", "cab", and "cba".

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

Samples

6
3
abc
4
xyyx
8
alphabet
1
k
10
aabbccddee
6
ttbddq
cbc
yyyx
alphaaet
k
eabbccddee
tttddq

在线编程 IDE

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