public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int T = sc . nextInt ( ) ;
  int min = Integer . MAX_VALUE ;
  int max = Integer . MIN_VALUE ;
  int ar [ ] [ ] = new int [ 2 ] [ T ] ;
  int result = - 1 ;
  for ( int i = 0 ;
  i < T ;
  i ++ ) {
    int first = sc . nextInt ( ) ;
    int second = sc . nextInt ( ) ;
    min = Math . min ( min , first ) ;
    max = Math . max ( max , second ) ;
    ar [ 0 ] [ i ] = first ;
    ar [ 1 ] [ i ] = second ;
  }
  for ( int i = 0 ;
  i < T ;
  i ++ ) {
    if ( ar [ 0 ] [ i ] == min && ar [ 1 ] [ i ] == max ) {
      result = i + 1 ;
      break ;
    }
  }
  System . out . println ( result ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; int ar [ ] [ ] = new int [ 2 ] [ T ] ; int result = - 1 ; for ( int i = 0 ; i < T ; i ++ ) { int first = sc . nextInt ( ) ; int second = sc . nextInt ( ) ; min = Math . min ( min , first ) ; max = Math . max ( max , second ) ; ar [ 0 ] [ i ] = first ; ar [ 1 ] [ i ] = second ; } for ( int i = 0 ; i < T ; i ++ ) { if ( ar [ 0 ] [ i ] == min && ar [ 1 ] [ i ] == max ) { result = i + 1 ; break ; } } System . out . println ( result ) ; }
(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) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (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)) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (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: (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) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)) right: (identifier))))) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)) right: (identifier)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)) right: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (break_statement))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))