IZBORNIK | 프로그래밍의 벗 PivotOJ
PivotOJ

IZBORNIK

시간 제한: 2000ms메모리 제한: 128MB출처: CHC 2008 National Competition #1 - JuniorsBOJ 1283

문제

The menu in a computer program contains N options. Each option is described by one or more words. 

Each option in the menu, in order from first to last, is assigned a shortcut – one of the letters in its description. The rules for assigning the shortcut are: 

  • First consider the initial letters of all words in the description, in order from first to last. The first such initial letter not already to another option is selected (no two options may have the same shortcut). 
  • If all initial letters are already assigned, then consider all remaining letters in the description in order, again choosing the first available letter. 
  • If none of the letters in the description are available, then the option has no shortcut. 
  • The process is not case sensitive; lowercase and uppercase letters are considered the same. 

Write a program which, given the descriptions of all options, determines the shortcuts. 

입력

The first line contains the integer N (1 ≤ N ≤ 30), the number of options in the menu. 

Each of the following N lines contains the description of one option, a sequence of at most 5 words separated by single spaces. Each word will contain at most 10 letters of the English alphabet. 

출력

For each option, in the same order in which they were given, output its description with the shortcut letter surrounded by brackets. If an option is not assigned a shortcut, output its description unchanged. 

The case of all letters must be the same as in the input.

예제

예제 1

입력
5
New
Open
Save
Save As
Save All
출력
[N]ew
[O]pen
[S]ave
Save [A]s
Sa[v]e All

예제 2

입력
8
New window
New file
Copy
Undo
Format
Font
Cut
Paste
출력
[N]ew window
New [f]ile
[C]opy
[U]ndo
F[o]rmat
Fon[t]
Cut
[P]aste
코드를 제출하려면 로그인하세요.