#K71872. Count Colors

    ID: 33628 Type: Default 1000ms 256MiB

Count Colors

Count Colors

Given a list of color names, count the occurrences of each color and output the results in alphabetical order.

In this problem, you are provided with an integer n followed by n lines where each line contains a color name. Your task is to compute the frequency of each color and print each unique color and its count on a separate line, with the color names sorted in alphabetical order.

For example, if the input is:
6
red
blue
red
green
blue
blue

The correct output is:
blue 3
green 1
red 2

inputFormat

The input is given via standard input (stdin) and contains multiple lines. The first line contains an integer n, which represents the number of colors. The following n lines each contain a single string denoting a color.

outputFormat

Print the frequency of each unique color on separate lines. Each line should contain the color name and its count separated by a space. The colors must be printed in alphabetical order.## sample

1
red
red 1

</p>