LEXISORT - Easy Sorting

no tags 

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

hide comments
nadstratosfer: 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.

vikasvik934: 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.

La Van Tien: 2017-04-01 19:13:52

oops!

Last edit: 2017-04-01 19:14:41
Avi Aryan: 2015-10-29 15:26:44

sort over string vector works too 0.03s

Abhinandan Agarwal: 2015-05-30 01:54:56

And improved implementation of radix sort through structures gave 0.01s . Still waiting for 0.00s ...

Last edit: 2015-05-30 02:09:14
ankur : 2015-01-02 13:46:40

i am getting WA, i have checked it on hundreds of different cases on ideone, but no idea

Shubham Singh: 2014-11-25 05:16:26

poor documentation of problem. what is n and c.

Kaushik: 2014-04-11 14:57:31

STL MAP :D

Changming: 2013-07-04 03:17:26

Quick Sort is enough for this problem.

Chandan Singh: 2013-06-28 19:01:52

you can use quick sort.


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