#C14137. Group Strings by First Letter

    ID: 43753 Type: Default 1000ms 256MiB

Group Strings by First Letter

Group Strings by First Letter

Given a list of strings, your task is to group them according to the first letter of each string, ignoring the character case. If a string is empty, it should be skipped. For each group, the first letter (in lowercase) is the key and the corresponding value is the list of the original strings (in the same order they appear in the input). The final output should list each group ordered by the key in ascending lexicographical order.

In other words, if you denote a string by \( s \) and its first character (if \( s \neq "" \)) by \( s_0 \), then the key is given by \( \mathrm{lower}(s_0) \) and all strings with the same key are grouped together.

inputFormat

The first line of the input contains an integer \( n \), representing the number of strings. The following \( n \) lines each contain one string.

outputFormat

For each unique first letter (in lowercase) that appears from the non-empty strings, output a line containing the letter, followed by the group of strings (in their original form and the order they were given) separated by spaces. The groups must be printed in ascending order of their keys.

## sample
4
apple
apricot
banana
blueberry
a apple apricot

b banana blueberry

</p>