public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int n = sc . nextInt ( ) ;
  int plot [ ] = new int [ 1000 ] ;
  for ( int i = 0 ;
  i < plot . length ;
  i ++ ) {
    plot [ i ] = 0 ;
  }
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    String baseTime = sc . next ( ) ;
    String times [ ] = baseTime . split ( "-" ) ;
    int startTime = Integer . parseInt ( times [ 0 ] ) ;
    int endTime = Integer . parseInt ( times [ 1 ] ) ;
    int start = startTime - ( startTime % 5 ) ;
    int end = endTime + ( 5 - ( endTime % 5 ) == 5 ? 0 : 5 - ( endTime % 5 ) ) ;
    if ( end % 100 > 59 ) {
      end += 100 - 60 + ( end % 100 - 60 ) ;
    }
    int startIndex = start / 5 ;
    int endIndex = end / 5 ;
    for ( int j = startIndex ;
    j < endIndex ;
    j ++ ) {
      plot [ j ] = 1 ;
    }
  }
  boolean startFlag = false ;
  for ( int i = 0 ;
  i < plot . length ;
  i ++ ) {
    if ( ! startFlag ) {
      if ( plot [ i ] == 1 ) {
        System . out . print ( String . format ( "%04d" , ( i * 5 ) ) + "-" ) ;
        startFlag = true ;
      }
    }
    else {
      if ( plot [ i ] == 0 ) {
        System . out . println ( String . format ( "%04d" , ( i * 5 ) ) ) ;
        startFlag = false ;
      }
    }
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int plot [ ] = new int [ 1000 ] ; for ( int i = 0 ; i < plot . length ; i ++ ) { plot [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { String baseTime = sc . next ( ) ; String times [ ] = baseTime . split ( " - " ) ; int startTime = Integer . parseInt ( times [ 0 ] ) ; int endTime = Integer . parseInt ( times [ 1 ] ) ; int start = startTime - ( startTime % 5 ) ; int end = endTime + ( 5 - ( endTime % 5 ) == 5 ? 0 : 5 - ( endTime % 5 ) ) ; if ( end % 100 > 59 ) { end += 100 - 60 + ( end % 100 - 60 ) ; } int startIndex = start / 5 ; int endIndex = end / 5 ; for ( int j = startIndex ; j < endIndex ; j ++ ) { plot [ j ] = 1 ; } } boolean startFlag = false ; for ( int i = 0 ; i < plot . length ; i ++ ) { if ( ! startFlag ) { if ( plot [ i ] == 1 ) { System . out . print ( String . format ( " % 04d " , ( i * 5 ) ) + " - " ) ; startFlag = true ; } } else { if ( plot [ i ] == 0 ) { System . out . println ( String . format ( " % 04d " , ( i * 5 ) ) ) ; startFlag = false ; } } } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (parenthesized_expression (ternary_expression condition: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (binary_expression left: (decimal_integer_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (decimal_integer_literal)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (true)))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (expression_statement (assignment_expression left: (identifier) right: (false)))))))))))