#PCPC12D. New Strategy

New Strategy

 

Meeda will compete this year in the ACM-ICPC world finals, but he is a crazy guy, he created a new strategy to attack the problem set. His new strategy is to solve the problems according to their names. He’ll sort the problem set according to the following rules.
Remove all whitespace characters from the problem names.
Replace any capital letters with the corresponding small one. i.e ‘A’ will be ‘a’
count the occurrence of each character
Problem A comes before problem B, if A contains lexicographically smaller characters more than B i.e A = “cba” comes before B = “bc” because A contains 1 'a' and B contains 0 'a'.
But as you may know that meeda is a very lazy guy and he needs to train for this strategy before the world finals, so he needs your help to write an efficient program to help him in the training.
Input Specification
The first line of the input contains T, number of test cases, each test case starts with an integer n (0<n<1000) number of problems, follow n lines each containing string s. The ith line is the name of the ith problem. s will be a sequence of characters (a-z, A-Z or any white space character), length of s is less than 100 characters.
Output Specification
First line of each test case should contains “case: ” without double quotes followed by the test case number starting from 1, then follow problem names sorted as described above.
Sample Input
2
2
abc
ab
4
bcsaasd
dbasaaaa
azzz
bayy
Sample Output
case: 1
ab
abc
case: 2
dbasaaaa
bcsaasd
bayy
azzz

 

Meeda will compete this year in the ACM-ICPC world finals, but he is a crazy guy, he created a new strategy to attack the problem set. His new strategy is to solve the problems according to their names. He’ll sort the problem set according to the following rules.

Remove all whitespace characters from the problem names.

Replace any capital letters with the corresponding small one. i.e ‘A’ will be ‘a’

count the occurrence of each character

Problem A comes before problem B, if A contains lexicographically smaller characters more than B i.e A = “cba” comes before B = “bc” because A contains 1 'a' and B contains 0 'a'.

But as you may know that meeda is a very lazy guy and he needs to train for this strategy before the world finals, so he needs your help to write an efficient program to help him in the training.

Input Specification

The first line of the input contains T, number of test cases, each test case starts with an integer n (0<n<1000) number of problems, follow n lines each containing string s. The ith line is the name of the ith problem. s will be a sequence of characters (a-z, A-Z or any white space character), length of s is less than 200 characters.

Output Specification

First line of each test case should contains “case: ” without double quotes followed by the test case number starting from 1, then follow problem names sorted as described above.

Sample Input

2

2

abc

ab

4

bcsaasd

dbasaaaa

azzz

bayy


Sample Output

case: 1

abc

ab

case: 2

dbasaaaa

bcsaasd

bayy

azzz

 

note : sorry for the wrong description .

           max length is 200 .