시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB43403792.500%

문제

There are many acronyms that have the same letters with different meanings. For example, ISS could mean International Space Station, In School Suspension, Interstate Sporadic Squabbles, but it could not be Institutional Saliva Tester (IST, not ISS) nor could it be Intermural Sports Situational Comedies (ISSC not ISS).

Determine whether or not phrases fit the acronym, with the correct number of words and beginning letters. All words will begin with capital letters.

입력

The first line contains the number of data sets (maximum of 10). Each data set contains the acronym and the number of possibilities (maximum of 10) on one line, followed by each possibility on a separate line.

출력

Show the acronym on one line followed by the phrases that match that acronym each on one line.

예제 입력 1

4
ABC 4
American Broadcasting Company
Another Boring Computer Program
Alpha Beta Gamma
Another Brilliant Csteacher
UIL 3
Union Leaders Invitation
University Interscholastic League
Upstanding Important Leaders
CIA 4
Central Intelligence Agency
Computer Image Advertising
Coming In After Christmas
Clubbing Intelligent Aardvarks
TBBT 7
The Big Bang Theory
The Big Bama Tide
Two Boolean Byte TreeMaps
Thing Without An Important Name
Tuning Big Brass Tubas
This Bytes Big Boogies Totally
Disk Operating System

예제 출력 1

ABC
American Broadcasting Company
Another Brilliant Csteacher
UIL
University Interscholastic League
Upstanding Important Leaders
CIA 
Central Intelligence Agency
Computer Image Advertising
Clubbing Intelligent Aardvarks
TBBT
The Big Bang Theory
The Big Bama Tide
Two Boolean Byte TreeMaps
Tuning Big Brass Tubas