import java.util.Scanner;

public class Club6
{
    // an array containing the count for each letter
    int counts[] = new int[256];
    
    /** Count the dues for each transaction
     * @param instream the Scanner from which to read names and payment.
     */
    public void collectDues(Scanner instream)
    {
        // Read all the transactions
        while (instream.hasNext())
        {
            // Get the name and payment
            String name = instream.next();
            int payment =  instream.nextInt();
            // Convert to a table index
            char letter = name.charAt(0);
            int index = (int) letter;
            // Increment the count table at that index 
            counts[index] += payment;
        }
    }

    /* Display results */
    public void report()
    {      
        // Show the total dues collected for each member
        for (int i = 0; i < 256; i++)
        {
            if (counts[i] > 0)
            {
                System.out.println((char) i + " " + counts[i]);
            }
        }
    }
    
    /** The application main method.  */
    public static void main(String args[])
    {
        // Open standard input for reading the text
        Scanner console = new Scanner(System.in);
        Club6 app = new Club6();
        app.collectDues(console);
        app.report();
    }
}