// Arup Guha
// 4/22/2021
// Solution to 2021 NADC Problem I: Simple Cron Spec

import java.util.*;

public class i {

	public static void main(String[] args) {
	
		// This many seconds in a day!
		boolean[] used = new boolean[86400];
		
		int total = 0;
		
		// Get input.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		// Go through each event.
		for (int i=0; i<n; i++) {
		
			// Get the lists of these valid hours, minutes and seconds.
			ArrayList<Integer> hrList = getList(stdin.next(), 24);
			ArrayList<Integer> minList = getList(stdin.next(), 60);
			ArrayList<Integer> secList = getList(stdin.next(), 60);
			
			// Total # of seconds.
			total += (hrList.size()*minList.size()*secList.size());
			
			// Just go through and set all of these to true.
			for (Integer x: hrList)
				for (Integer y: minList)
					for (Integer z: secList) 
						used[3600*x+60*y+z] = true;
		}
		
		// Now we can count unique.
		int unique = 0;
		for (int i=0; i<86400; i++)
			if (used[i])
				unique++;
				
		// Ta da!
		System.out.println(unique+" "+total);
	}
	
	// Returns the list of values.
	public static ArrayList<Integer> getList(String s, int limit) {
	
		// Easy case.
		ArrayList<Integer> res = new ArrayList<Integer>();
		if (s.equals("*")) {
			for (int x=0; x<limit; x++) res.add(x);
			return res;
		}
		
		// Split this up.
		StringTokenizer tok = new StringTokenizer(s, ",");
		while (tok.hasMoreTokens()) {
		
			// Get this token!
			String cur = tok.nextToken();
			
			// This could be further split...
			StringTokenizer tok2 = new StringTokenizer(cur, "-");
			int start = Integer.parseInt(tok2.nextToken());
			int end = start;
			if (tok2.hasMoreTokens()) end = Integer.parseInt(tok2.nextToken());
			
			// Add these items here.
			for (int i=start; i<=end; i++) res.add(i);
		}
		
		// Ta da!
		return res;
	}
}