public static void main ( String [ ] __ ) {
  int [ ] from , to ;
  {
    String buf = s . next ( ) ;
    from = new int [ buf . length ( ) + 1 ] ;
    for ( int i = 0 ;
    i < buf . length ( ) ;
    i ++ ) from [ i + 1 ] = buf . charAt ( i ) == 'A' ? 1 : 2 ;
    buf = s . next ( ) ;
    to = new int [ buf . length ( ) + 1 ] ;
    for ( int i = 0 ;
    i < buf . length ( ) ;
    i ++ ) to [ i + 1 ] = buf . charAt ( i ) == 'A' ? 1 : 2 ;
    Arrays . parallelPrefix ( from , ( a , b ) -> a + b ) ;
    Arrays . parallelPrefix ( to , ( a , b ) -> a + b ) ;
  }
  for ( int q = s . nextInt ( ) ;
  q > 0 ;
  q -- ) {
    int f = - from [ s . nextInt ( ) - 1 ] + from [ s . nextInt ( ) ] , t = - to [ s . nextInt ( ) - 1 ] + to [ s . nextInt ( ) ] ;
    System . out . println ( f % 3 == t % 3 ? "YES" : "NO" ) ;
  }
}

public static void main ( String [ ] __ ) { int [ ] from , to ; { String buf = s . next ( ) ; from = new int [ buf . length ( ) + 1 ] ; for ( int i = 0 ; i < buf . length ( ) ; i ++ ) from [ i + 1 ] = buf . charAt ( i ) == ' A ' ? 1 : 2 ; buf = s . next ( ) ; to = new int [ buf . length ( ) + 1 ] ; for ( int i = 0 ; i < buf . length ( ) ; i ++ ) to [ i + 1 ] = buf . charAt ( i ) == ' A ' ? 1 : 2 ; Arrays . parallelPrefix ( from , ( a , b ) -> a + b ) ; Arrays . parallelPrefix ( to , ( a , b ) -> a + b ) ; } for ( int q = s . nextInt ( ) ; q > 0 ; q -- ) { int f = - from [ s . nextInt ( ) - 1 ] + from [ s . nextInt ( ) ] , t = - to [ s . nextInt ( ) - 1 ] + to [ s . nextInt ( ) ] ; System . out . println ( f % 3 == t % 3 ? " YES " : " NO " ) ; } }
(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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (ternary_expression condition: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (ternary_expression condition: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (lambda_expression parameters: (inferred_parameters (identifier) (identifier)) body: (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (lambda_expression parameters: (inferred_parameters (identifier) (identifier)) body: (binary_expression left: (identifier) right: (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) right: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) right: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (ternary_expression condition: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (string_literal) alternative: (string_literal)))))))))