Under construction

Still being built. Things may change

Letter Counter

Interview

Time limit1sMemory limit512 MB

Summary
Count how many times each letter appears across the given lines and print nonzero counts from a to z then A to Z.
Level

Easy1 of 10

Topics
Array, String
Solved
No attempts yet

Problem

A club of young code-breaking enthusiasts is building software to decrypt an ancient manuscript. The heart of the system will be a self-learning text analyzer, and its first module, a 'letter counter', has been entrusted to you.

Write a program that:

  • reads the text to analyze from standard input,
  • for each letter, counts how many times it appears in the text,
  • prints the result to standard output.

Input

The first line contains an integer NN, the number of text lines to analyze (N≤150N \le 150). Each of the next NN lines contains a string of at most 200200 characters made up of lowercase and uppercase Latin letters ('a'..'z', 'A'..'Z') and spaces.

Output

For the letters 'a' through 'z' and then 'A' through 'Z' (in that order), print one line for each letter that appears in the text: the letter, a single space, and the number of times it occurs. Skip any letter that does not appear in the text.

Examples2

  1. Example 1

    Input
    2
    ala ma kota
    Ola ma psa
    
    Expected output
    a 7
    k 1
    l 2
    m 2
    o 1
    p 1
    s 1
    t 1
    O 1
    
  2. Example 2

    Input
    1
    aAaAbZ
    
    Expected output
    a 2
    b 1
    A 2
    Z 1