// Arup Guha
// 8/18/2026
// Example for COP 3330 using a TreeMap
// This example processes votes and prints out the current standings (sorted in
// alphabetical order by name) of the votes currently received.

import java.util.*;

public class votes {

	public static void main(String[] args) {
	
		// Get number of commands.
		Scanner stdin = new Scanner(System.in);
		int numCmd = stdin.nextInt();
		
		// Will store all votes here.
		TreeMap<String,Integer> myMap = new TreeMap<String,Integer>();
	
		// Process commands.
		for (int loop=0; loop<numCmd; loop++) {
		
			// Get type.
			int type = stdin.nextInt();
		
			// Processing adding a vote.
			if (type == 1) {
			
				// Get the name.
				String name = stdin.next();
				
				// Just add one vote.
				if (myMap.containsKey(name))
					myMap.put(name, myMap.get(name)+1);
				
				// First vote, just place it!
				else	
					myMap.put(name, 1);
			}
			
			// Print status.
			else {
				for (String candidate: myMap.keySet())
					System.out.println(candidate+" "+myMap.get(candidate));
				System.out.println();
			}
		}
	}
}