import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Solution to Simple Cron Spec.
 *
 * @author vanb
 */
public class cron_vanb
{
    /** Input. */
    private static Scanner sc;
    
    /** Output. */
    private static PrintStream ps;
    
    /**
     * Parses a spec, returning a list of all the (hours | minutes | seconds) specified.
     *
     * @param spec the spec
     * @param max the max (24 for hours, 60 for minutes or seconds)
     * @return the list
     */
    private List<Integer> parse( String spec, int max )
    {
        List<Integer> result = new ArrayList<Integer>(max); 
        if( spec.contains( "*" ) )
        {
            for( int i=0; i<max; i++ ) result.add( i );
        }
        else
        {
            String tokens[] = spec.split( "," );
            for( String token : tokens )
            {
                if( token.contains( "-" ) )
                {
                    String parts[] = token.split( "-" );
                    int lo = Integer.parseInt( parts[0] );
                    int hi = Integer.parseInt( parts[1] );
                    for( int i=lo; i<=hi; i++ ) result.add( i );
                }
                else result.add( new Integer(token) );
            }
        }
        
        return result;
    }
    
    /**
     * Do it!.
     */
    private void doit()
    {
        boolean times[][][] = new boolean[24][60][60];
        for( int h=0; h<24; h++) for( int m=0; m<60; m++ ) Arrays.fill( times[h][m], false );

        int n = sc.nextInt();
        
        int totalJobs = 0;
        
        while( n-->0 )
        {
            List<Integer> hours = parse( sc.next(), 24);
            List<Integer> minutes = parse( sc.next(), 60 );
            List<Integer> seconds = parse( sc.next(), 60 );
            
            totalJobs += hours.size()*minutes.size()*seconds.size();
            
            
            for( int h : hours ) for( int m : minutes ) for( int s : seconds ) times[h][m][s] = true;
        }
        
        int totalSeconds = 0;
        for( boolean[][] h : times ) for( boolean[] m : h ) for( boolean s : m ) if( s ) ++totalSeconds;  
        
        ps.println( totalSeconds + " " + totalJobs );
    }
        
    /**
     * Main.
     *
     * @param args unused
     * @throws Exception the exception
     */
    public static void main( String[] args ) throws Exception
    {
        sc = new Scanner( System.in );
        ps = System.out;
        
        new cron_vanb().doit();
    }

}
