import java.io.*;
import java.util.*;
import java.math.*;

public class q4 
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader bf = new BufferedReader(new FileReader("DATA3.txt"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("OUT3.txt")));

		for (int i = 0; i < 5; i++)
		{
			HashMap<String, Integer> total = new HashMap<String, Integer>();
			
			String s = "";
			
			bf.readLine();
			bf.readLine();
			
			int t = 0;
			int sum = 0;
			
			while(!(s = bf.readLine()).equals("---"))
			{
				String k[] = s.split(" ");
				int num = Integer.parseInt(k[1]);
				
				if (total.containsKey(k[0]))
				{
					t--;
					sum += Math.abs(num - total.get(k[0]));
				}
				else
				{
					total.put(k[0], num);
					t++;
				}
			}
			
			out.println(t + " " + sum);
		}
		
		out.close();
	}

}
