let () = Scanf.scanf "%s\n%s\n%d\n" @@ fun s t q ->
  let count_s = Array.make (String.length s + 1) 0 in
  let count_t = Array.make (String.length t + 1) 0 in
  String.iteri (fun i c ->
    count_s.(i + 1) <- count_s.(i) + if c = 'A' then 1 else 2) s;
  String.iteri (fun i c ->
    count_t.(i + 1) <- count_t.(i) + if c = 'A' then 1 else 2) t;
  for i = 0 to q - 1 do
    Scanf.scanf "%d %d %d %d\n" @@ fun a b c d ->
      print_endline @@ 
      if (count_s.(b) - count_s.(a - 1)) mod 3 = (count_t.(d) - count_t.(c - 1)) mod 3 then "YES" else "NO"
  done
