题目描述
Problem description.
Most campuses have a lot of named buildings, and as the names tend to be rather long, the class schedules
have abbreviations. At IITD, it seems that the abbreviations have become used so widely that most people
don’t even remember the full name of the building, such as SAC. To a newcomer, this can be quite confusing. So perhaps, we ought to write a little program that finds out which building could be meant by abbreviations.
Here’s how we’ll do it: you will be given a list of building names, and a building abbreviation, such as SAC or BB. The abbreviation matches the building name if all of its letters appear, in this order, in the building name (no letter can be matched twice). So, for instance, SAC matches “SAnCtum”, or “Student Activity Centre”. It does not match “Atmospheric Sciences Centre”, as the letters are in the wrong order. For the comparison, we will ignore case, so ‘S’ and ‘s’ are the same letter.
Input
The first line contains a number K , which is the number of input data sets in the file. This is followed by K data sets of the following form:
The first line of the data set contains the number N of buildings. This is followed by N lines, each containing the name of a building, consisting of only uppercase and lowercase letters and white space.
Finally, the building code will follow on a line by itself.
Output
For each data set, first output “Data Set x:” on a line by itself, where x is its number. Then, output all of the building names that match the building code, each on its own line, and in the order in which they appeared in the initial list.
Constraints
1 ≤ K ≤ 20
1 ≤ N ≤ 100
Example
Input:
2
2
SaLvatori
Science LibrarieS
SSL
3
studENt aeRoSpace laBoratory
salVAtori
angeles
SAL
Output:
Data Set 1:
Data Set 2:
studENt aeRoSpace laBoratory
salVAtori
输入格式
见题面
输出格式
见题面