import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  s <- getLine
  t <- getLine
  q <- readLn :: IO Int

  let
    ss = listArray (0,length s) $ scanl add (0,0) (map (\c -> if c=='A' then (1,0) else (0,1)) s)
    tt = listArray (0,length t) $ scanl add (0,0) (map (\c -> if c=='A' then (1,0) else (0,1)) t)

  replicateM_ q $ do
    [a,b,c,d] <- map read . words <$> getLine :: IO [Int]
    let
      (sa,sb) = (ss!b) `sub` (ss!(a-1))
      (ta,tb) = (tt!d) `sub` (tt!(c-1))

    putStrLn $ if (sa+2*sb)`mod`3 == (ta+2*tb)`mod`3 then "YES" else "NO"
  
  
add (a,b) (c,d) = (a+c,b+d)
sub (a,b) (c,d) = (a-c,b-d)
