LEXISORT - Easy Sorting

Given is a list of words and a lexicographical ordering according to the ascii alphabet. Your task is to sort the words in increasing order.

Input

The first line contains the numbers of test cases k (k< 100). Every test case consists of n+1 (1 < n < 50000) lines. Each line contains of a string of 10 characters. The first line of each test case contains n.

Output

Output the sorted list of words.

Example

Input:
2
2
helloworld
worldhello
2
aaaaaaaaaa
Aaaaaaaaaa

Output:
helloworld
worldhello
Aaaaaaaaaa
aaaaaaaaaa

Added by:Simon
Date:2005-04-13
Time limit:1s
Source limit:8083B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET

hide comments
2021-01-11 16:30:51
"My code is great, it's the computer that's wrong." -- says the guy missing the good old days of SPOJ, which would be a month ago, when he began using it.
2021-01-11 09:47:37
java gives tle or wrong answer . i sorted vector in c++ and worked somehow.Quality of spoj is so poor now a days.
2017-04-01 19:13:52 La Van Tien
oops!

Last edit: 2017-04-01 19:14:41
2015-10-29 15:26:44 Avi Aryan
sort over string vector works too 0.03s
2015-05-30 01:54:56 Abhinandan Agarwal
And improved implementation of radix sort through structures gave 0.01s . Still waiting for 0.00s ...

Last edit: 2015-05-30 02:09:14
2015-01-02 13:46:40 ankur
i am getting WA, i have checked it on hundreds of different cases on ideone, but no idea
2014-11-25 05:16:26 Shubham Singh
poor documentation of problem. what is n and c.
2014-04-11 14:57:31 Kaushik
STL MAP :D
2013-07-04 03:17:26 Changming
Quick Sort is enough for this problem.
2013-06-28 19:01:52 Chandan Singh
you can use quick sort.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.