#C1204. Categorize Flowers by Color
Categorize Flowers by Color
Categorize Flowers by Color
You are given an integer \(n\) representing the number of flowers, followed by \(n\) lines each containing a flower name and its corresponding color. Your task is to group the flowers by their colors and output each group in a specific order.
The groups must be arranged in alphabetical order of the color names. Within each group, the flower names should also be sorted in alphabetical order. The output should first display the color and then list all the flower names for that color on separate lines.
For example, if the input is:
7 rose red tulip yellow daisy white sunflower yellow lily red orchid white violet blue
Then the correct output would be:
blue violet red lily rose white daisy orchid yellow sunflower tulip
Pay careful attention to the order in which the colors and names are printed.
inputFormat
The first line of input contains an integer \(n\) (\(1 \le n\)). Each of the following \(n\) lines contains two strings: the first represents the flower name and the second represents its color. The flower name and color are separated by whitespace.
outputFormat
Output the categorized flowers. For each unique color (in alphabetical order), first print the color, then print the flower names belonging to that color (each on a new line) in alphabetical order.
## sample7
rose red
tulip yellow
daisy white
sunflower yellow
lily red
orchid white
violet blue
blue
violet
red
lily
rose
white
daisy
orchid
yellow
sunflower
tulip
</p>