import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.Unboxed
import qualified Data.Vector.Unboxed as VU
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readIntBS = fst . fromJust . BS.readInt

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

  let
    ls = BS.length s
    lt = BS.length t
    sa = VU.fromList $ scanl (+) 0 [if BS.index s i=='A' then 1 else 0 | i<-[0..ls-1]] :: VU.Vector Int
    sb = VU.fromList $ scanl (+) 0 [if BS.index s i=='A' then 0 else 1 | i<-[0..ls-1]] :: VU.Vector Int
    ta = VU.fromList $ scanl (+) 0 [if BS.index t i=='A' then 1 else 0 | i<-[0..lt-1]] :: VU.Vector Int
    tb = VU.fromList $ scanl (+) 0 [if BS.index t i=='A' then 0 else 1 | i<-[0..lt-1]] :: VU.Vector Int
 
  replicateM_ q $ do
    [a,b,c,d] <- map readIntBS . BS.words <$> BS.getLine :: IO [Int]
    let
      sa' = (sa VU.! b) - (sa VU.! (a-1))
      sb' = (sb VU.! b) - (sb VU.! (a-1))
      ta' = (ta VU.! d) - (ta VU.! (c-1))
      tb' = (tb VU.! d) - (tb VU.! (c-1))

    putStrLn $ if (sa'+2*sb')`mod`3 == (ta'+2*tb')`mod`3 then "YES" else "NO"
  