问题 B: Front Or Back

问题 B: Front Or Back

时间限制: 2 Sec  内存限制: 128 MB
提交: 32  解决: 11
[状态] [讨论版] [提交] [命题人:]
题目描述

You have a string S, initially the length is zero.
I will give you n characters, each time you can put the character beyond S or behind S, for
instance, if S = “abc”, the character is ‘x’, then , you can get “xabc” or “abcx”.
After n operations, i want to get a string which lexicographically is largest.

输入

Input starts with an integer T(1 <= T <= 20), denoting the number of test cases.
Each test case contains an integer n(1 <= n <= 2*10^3), denoting the number characters,
Next n line, each line contains a lower-case letter.

输出

For each test case, print a string which lexicographically is largest.

样例输入 Copy
1
5
a
b
c
d
e
样例输出 Copy
edcba