cho.sh
Notes
Loading...

Shortcut Key Assignment

Time limit

2s

Memory limit

128 MB

Problem

A program menu has N options. Each option consists of one or more words describing what the option does. Process the options from top to bottom and assign one representative alphabet letter as the shortcut key for each option. Use the following rules.

  1. For one option, check the first letter of each word from left to right. If that letter has not been used as a shortcut key yet, assign it to this option.
  2. If the first letters of all words have already been used, scan the whole option from left to right and assign the first alphabet letter that has not been used yet.
  3. If no letter can be assigned, leave the option unchanged. Uppercase and lowercase letters are considered the same.
  4. Apply these rules in order from the 1st option to the Nth option.

Input

The first line contains the number of options N (1 ≤ N ≤ 30). Each of the next N lines contains one option string. An option consists of at most 5 words, and each word consists of at most 10 alphabet letters. Adjacent words are separated by one space.

Output

Print the N options in input order. Surround the alphabet letter assigned as a shortcut key with [ and ].