#C13319. Group Words by Starting Letter

    ID: 42844 Type: Default 1000ms 256MiB

Group Words by Starting Letter

Group Words by Starting Letter

Given a list of words, your task is to group them by their starting letter in a case-insensitive manner. That is, the grouping key for a word is defined as \( \text{lowercase}(word[0]) \).

After grouping the words, output each group on a separate line. Each line should begin with the lowercase letter followed by a colon, a space, and then the words belonging to that group in the order they appear in the input. The groups must be printed in alphabetical order of the letters.

If no words are provided, output nothing.

inputFormat

The first line of input contains an integer \( n \) indicating the number of words.

This is followed by \( n \) words separated by spaces or newlines. Each word consists of alphabets.

outputFormat

For each distinct starting letter (in lowercase) that appears in the input, print a line in the following format:

( letter: word1 word2 \dots )

The groups should be printed in ascending alphabetical order of the letters. There should be a single space between words. If no words are provided, do not print anything.

## sample
4
Banana apple Apricot blueberry
a: apple Apricot

b: Banana blueberry

</p>