아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

약어 판별

면접 대비

시간 제한1초메모리 제한256 MB

요약
머릿글자와 후보 구문이 주어지면 단어 수와 각 단어 첫 글자가 머리글자와 일치하는 구문을 순서대로 출력합니다.
난이도

쉬움10점 중 1점

유형
문자열, 구현
정답자
아직 제출이 없습니다

문제

글자는 같지만 뜻이 다른 약어가 많다. ISS는 International Space Station일 수도 있고, In School Suspension일 수도 있고, Interstate Sporadic Squabbles일 수도 있다. 반면 Institutional Saliva Tester는 줄이면 IST가 되므로 ISS가 아니고, Intermural Sports Situational Comedies는 줄이면 ISSC가 되므로 ISS가 아니다.

문구가 약어에 맞으려면 단어의 개수가 약어의 글자 수와 같아야 하고, 각 단어의 첫 글자가 같은 자리에 있는 약어의 글자와 같아야 한다. 모든 단어는 대문자로 시작한다.

약어와 후보 문구 목록이 주어진다. 약어에 맞는 문구를 찾아라.

입력

첫 줄에 데이터 집합의 개수가 주어진다. 최대 10이다.

각 데이터 집합의 첫 줄에는 약어와 후보 문구의 개수가 공백으로 구분되어 주어진다. 후보 문구의 개수는 최대 10이다. 다음 줄부터 후보 문구가 한 줄에 하나씩 주어진다.

출력

각 데이터 집합마다 약어를 한 줄에 출력하고, 이어서 약어에 맞는 문구를 입력에 주어진 순서대로 한 줄에 하나씩 출력한다. 맞는 문구가 없으면 약어만 출력한다.

예제2

  1. 예제 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
    
    예상 출력
    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
    
  2. 예제 2

    입력
    2
    A 3
    Apple
    Banana
    Awesome Aardvark
    Z 1
    Zebra
    
    예상 출력
    A
    Apple
    Z
    Zebra