1891 Substring
Submit solution
Points:
100
Time limit:
1.0s
Memory limit:
32M
Problem types
Allowed languages
C, C++, Java, Python
Description
Dr. lee cuts a string S into N pieces, s[1],s[2],…,s[n]. There might be several possibilities that the string S could be. For example, if Dr. lee gives you three substrings {“a”,”ab”,”ac”}, the string S could be “aabac”, “aacab”, “abaac”,…
Your task is to output the lexicographically smallest S.
Input
The first line of the input is a positive integer T. T is the number of the test cases followed. The first line of each case is a positive integer N(1<=N<=100) which represents the number of substrings. After that , N strings followed. Assume that the length of each substring is positive and less than 100.
Output
The output of each test is the lexicographically smallest S. No redundant spaces are needed.
Sample
Input
1
3
a ab ac
Output
aabac
Comments