def inpl(): return [int(i) for i in input().split()]



S = eval(input())

T = eval(input())

typeS = [0 for _ in range(1+len(S))]

typeT = [0 for _ in range(1+len(T))]

typeS[0] = typeT[0] = 0 

for i in range(len(S)):

    ctr = 2

    if S[i] == 'A':

        ctr = 1

    typeS[i+1] = (typeS[i] + ctr)%3

for i in range(len(T)):

    ctr = 2

    if T[i] == 'A':

        ctr = 1

    typeT[i+1] = (typeT[i] + ctr)%3

Q = int(eval(input()))

for _ in range(Q):

    a, b, c, d = inpl()

    if (typeS[b] - typeS[a-1])%3 == (typeT[d] -typeT[c-1])%3:

        print('YES')

    else:

        print('NO')
import sys

from itertools import accumulate

readline = sys.stdin.readline



S = [1 if s == 'A' else 2 for s in readline().strip()]

T = [1 if s == 'A' else 2 for s in readline().strip()]

AS = [0] + list(accumulate(S))

AT = [0] + list(accumulate(T))

Q = int(readline())

Ans = [None]*Q 



for qu in range(Q):

    a, b, c, d = list(map(int, readline().split()))

    if (AS[b]-AS[a-1])%3 != (AT[d]-AT[c-1])%3:

        Ans[qu] = 'NO'    

    else:

        Ans[qu] = 'YES'



print(('\n'.join(map(str, Ans))))
def inpl():
    return [int(i) for i in input().split()]


S = eval(input())
T = eval(input())
typeS = [0 for _ in range(1 + len(S))]
typeT = [0 for _ in range(1 + len(T))]
typeS[0] = typeT[0] = 0
for i in range(len(S)):
    ctr = 2
    if S[i] == "A":
        ctr = 1
    typeS[i + 1] = (typeS[i] + ctr) % 3
for i in range(len(T)):
    ctr = 2
    if T[i] == "A":
        ctr = 1
    typeT[i + 1] = (typeT[i] + ctr) % 3
Q = int(eval(input()))
for _ in range(Q):
    a, b, c, d = inpl()
    if (typeS[b] - typeS[a - 1]) % 3 == (typeT[d] - typeT[c - 1]) % 3:
        print("YES")
    else:
        print("NO")

import sys
from itertools import accumulate

readline = sys.stdin.readline
S = [1 if s == "A" else 2 for s in readline().strip()]
T = [1 if s == "A" else 2 for s in readline().strip()]
AS = [0] + list(accumulate(S))
AT = [0] + list(accumulate(T))
Q = int(readline())
Ans = [None] * Q
for qu in range(Q):
    a, b, c, d = list(map(int, readline().split()))
    if (AS[b] - AS[a - 1]) % 3 != (AT[d] - AT[c - 1]) % 3:
        Ans[qu] = "NO"
    else:
        Ans[qu] = "YES"
print(("\n".join(map(str, Ans))))

-def inpl(): -    return [int(i) for i in input().split()] +import sys +from itertools import accumulate - -S = eval(input()) -T = eval(input()) -typeS = [0 for _ in range(1 + len(S))] -typeT = [0 for _ in range(1 + len(T))] -typeS[0] = typeT[0] = 0 -for i in range(len(S)): -    ctr = 2 -    if S[i] == "A": -        ctr = 1 -    typeS[i + 1] = (typeS[i] + ctr) % 3 -for i in range(len(T)): -    ctr = 2 -    if T[i] == "A": -        ctr = 1 -    typeT[i + 1] = (typeT[i] + ctr) % 3 -Q = int(eval(input())) -for _ in range(Q): -    a, b, c, d = inpl() -    if (typeS[b] - typeS[a - 1]) % 3 == (typeT[d] - typeT[c - 1]) % 3: -        print("YES") +readline = sys.stdin.readline +S = [1 if s == "A" else 2 for s in readline().strip()] +T = [1 if s == "A" else 2 for s in readline().strip()] +AS = [0] + list(accumulate(S)) +AT = [0] + list(accumulate(T)) +Q = int(readline()) +Ans = [None] * Q +for qu in range(Q): +    a, b, c, d = list(map(int, readline().split())) +    if (AS[b] - AS[a - 1]) % 3 != (AT[d] - AT[c - 1]) % 3: +        Ans[qu] = "NO" -        print("NO") +        Ans[qu] = "YES" +print(("\n".join(map(str, Ans))))