#K131. Lexicographically Smallest String Transformation

    ID: 23837 Type: Default 1000ms 256MiB

Lexicographically Smallest String Transformation

Lexicographically Smallest String Transformation

You are given a string S of length N. You are allowed to perform at most one operation on the string. There are two possible operations:

  • Operation 1: Reverse the entire string S to obtain SR.
  • Operation 2: Replace S with a string consisting of N copies of the lowercase letter 'a'. That is, obtain the string \(a^N\).

Your task is to choose at most one of these operations such that the resulting string is the lexicographically smallest possible. In other words, if we denote the two possible outcomes as \(S^R\) and \(a^N\), then you should output the string \[ \min\left(S^R,\,a^N\right). \]

Note: If N = 0, the string is empty and no operation is needed.

inputFormat

The input is given via standard input (stdin) and has the following format:

T
N1 S1
N2 S2
... 
NT ST

Here, T is the number of test cases. For each test case, the first token is an integer N denoting the length of the string, followed by a string S of length N. In the case when N = 0, the corresponding string S will be an empty string.

outputFormat

For each test case, print a single line containing the lexicographically smallest string obtained by performing at most one of the allowed operations. The output should be printed via standard output (stdout).

## sample
1
3 cba
aaa

</p>