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

/**
 * Validator for Simple Cron Spec, checking that the numbers are in increasing order.
 * Everything else is checked by the VIVA pattern.
 *
 * @author vanb
 */
public class cron_validator
{
    /** Input. */
    private static Scanner sc;
    
    /**
     * Parses a spec, testing that all numbers are in strictly increasing order.
     *
     * @param spec the spec
     * @return true if all is well, otherwise false
     */
    private static boolean  parse( String spec )
    {
        boolean ok = true;
        if( !spec.contains( "*" ) )
        {
            int last = -1;
            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] );
                    if( lo>=hi ) ok = false;
                    if( lo<=last ) ok = false;
                    last = hi;                    
                }
                else 
                {
                    int value = Integer.parseInt( token );
                    if( value<=last ) ok = false;
                    last = value;
                }
            }
        }
        return ok;
    }

        
    /**
     * Main.
     *
     * @param args unused
     * @throws Exception the exception
     */
    public static void main( String[] args ) throws Exception
    {
        sc = new Scanner( System.in );
        
        int n = sc.nextInt();
        boolean ok = true;
        
        while( n-->0 )
        {
            ok &= parse( sc.next() );
            ok &= parse( sc.next() );
            ok &= parse( sc.next() );            
        }

        System.exit( ok ? 42 : 0 );
    }

}
