CF1974B.Symmetric Encoding

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

Symmetric Encoding

Polycarp has a string ss, which consists of lowercase Latin letters. He encodes this string using the following algorithm:

  • first, he constructs a new auxiliary string rr, which consists of all distinct letters of the string ss, written in alphabetical order;
  • then the encoding happens as follows: each character in the string ss is replaced by its symmetric character from the string rr (the first character of the string rr will be replaced by the last, the second by the second from the end, and so on).

For example, encoding the string ss="codeforces" happens as follows:

  • the string rr is obtained as "cdefors";
  • the first character s1s_1='c' is replaced by 's';
  • the second character s2s_2='o' is replaced by 'e';
  • the third character s3s_3='d' is replaced by 'r';
  • ...
  • the last character s10s_{10}='s' is replaced by 'c'.

The string rr and replacements for ss="codeforces".

Thus, the result of encoding the string ss="codeforces" is the string "serofedsoc".

Write a program that performs decoding — that is, restores the original string ss from the encoding result.

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5) — the length of the string bb.

The second line of each test case contains a string bb of length nn, consisting of lowercase Latin letters — the result of encoding the original string ss.

It is guaranteed that the sum of the values of nn over all test cases in the test does not exceed 21052 \cdot 10^5.

Output

For each test case, output the string ss from which the encoding result bb was obtained.

Samples

5
10
serofedsoc
3
ttf
9
tlrhgmaoi
1
w
15
hnndledmnhlttin
codeforces
fft
algorithm
w
meetinthemiddle

在线编程 IDE

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