public static void main ( String [ ] $ ) {
  int n = scanner . nextInt ( ) , d = scanner . nextInt ( ) , k = scanner . nextInt ( ) ;
  int [ ] l = new int [ d ] , r = new int [ d ] , s = new int [ k ] , t = new int [ k ] , a = new int [ k ] ;
  boolean [ ] b = new boolean [ k ] ;
  for ( int i = 0 ;
  i < d ;
  i ++ ) {
    l [ i ] = scanner . nextInt ( ) ;
    r [ i ] = scanner . nextInt ( ) ;
  }
  for ( int i = 0 ;
  i < k ;
  i ++ ) b [ i ] = ( s [ i ] = scanner . nextInt ( ) ) < ( t [ i ] = scanner . nextInt ( ) ) ;
  for ( int i = 0 ;
  i < d ;
  i ++ ) {
    for ( int j = 0 ;
    j < k ;
    j ++ ) {
      if ( l [ i ] <= s [ j ] && s [ j ] <= r [ i ] ) {
        s [ j ] = b [ j ] ? Math . max ( s [ j ] , r [ i ] ) : Math . min ( s [ j ] , l [ i ] ) ;
        if ( ( b [ j ] ? s [ j ] >= t [ j ] : s [ j ] <= t [ j ] ) && a [ j ] == 0 ) a [ j ] = i + 1 ;
      }
    }
  }
  java . util . Arrays . stream ( a ) . forEach ( System . out :: println ) ;
}

public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , d = scanner . nextInt ( ) , k = scanner . nextInt ( ) ; int [ ] l = new int [ d ] , r = new int [ d ] , s = new int [ k ] , t = new int [ k ] , a = new int [ k ] ; boolean [ ] b = new boolean [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = scanner . nextInt ( ) ; r [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < k ; i ++ ) b [ i ] = ( s [ i ] = scanner . nextInt ( ) ) < ( t [ i ] = scanner . nextInt ( ) ) ; for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( l [ i ] <= s [ j ] && s [ j ] <= r [ i ] ) { s [ j ] = b [ j ] ? Math . max ( s [ j ] , r [ i ] ) : Math . min ( s [ j ] , l [ i ] ) ; if ( ( b [ j ] ? s [ j ] >= t [ j ] : s [ j ] <= t [ j ] ) && a [ j ] == 0 ) a [ j ] = i + 1 ; } } } java . util . Arrays . stream ( a ) . forEach ( System . out :: println ) ; }
(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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)))) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)))) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)))) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)))) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (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 (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (parenthesized_expression (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) right: (parenthesized_expression (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))) (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 (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: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (ternary_expression condition: (array_access array: (identifier) index: (identifier)) consequence: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (array_access array: (identifier) index: (identifier)))) alternative: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (array_access array: (identifier) index: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (ternary_expression condition: (array_access array: (identifier) index: (identifier)) consequence: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) alternative: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))) (expression_statement (method_invocation object: (method_invocation object: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (method_reference (field_access object: (identifier) field: (identifier)) (identifier)))))))