Character Frequencies
InterviewTime limit1sMemory limit1024 MB
Count how many times each non-whitespace character appears in N lines of text and print each character with its count.
Problem
John is preparing a printing press for a publication. He needs to check that he has enough type pieces, the small blocks of cast metal with character shapes on them. Write a program that counts how many times each character appears in his text.
Input
The first line contains , the number of lines in John's publication (). The next lines contain the text. Each line may consist of up to 100 characters. The text may contain uppercase and lowercase letters, digits, and punctuation marks.
Output
Print the frequency table of the characters that appear in the input text. On each line, print one character and its frequency (the number of times it appears in the text), separated by a space. The lines may be in any order. Spaces and line breaks are not counted as characters.