Different ethnic groups have developed local alphabets and this has led to an assortment of various sort orders. A sorting algorithm allowing universal support may be known as Alphabet Collating Universal (ACU). An ACU sort function orders a set of text strings given a specific collating sequence. According to the ACU standard, characters contained in a string to be sorted but not included in the collating sequence should be ignored.
Write a program to sort sets of text strings given an ACU sequence.
The first line consists of a positive integer indicating the number of data sets to process.
Each data set begins with a line containing a positive integer, M, indicating the number of words to be sorted in the data set. The next line consists of the collating sequence to be used for the data set. The next M lines contain one word each; these words are to be ACU sorted. No line will contain any whitespace or be longer than 1000 characters.
Sample input:2 4 0123456789 (325)674-2200 325-674-2000 (213)-458-0123 213-4580000 4 aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ Bob Abe able bee
Each data set should produce M+1 lines of output. The first M lines must contain the M words of the data set in ACU order given the collating sequence specified. Line M+1 must contain "--".
Sample output:213-4580000 (213)-458-0123 325-674-2000 (325)674-2200 -- able Abe bee Bob --