IZBORNIK
문제
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