Let us consider the following operations on a string consisting of A and B:
 - Select a character in a string. If it is A, replace it with BB. If it is B, replace with AA.
 - Select a substring that is equal to either AAA or BBB, and delete it from the string.
For example, if the first operation is performed on ABA and the first character is selected, the string becomes BBBA.
If the second operation is performed on BBBAAAA and the fourth through sixth characters are selected, the string becomes BBBA.
These operations can be performed any number of times, in any order.
You are given two string S and T, and q queries a_i, b_i, c_i, d_i.
For each query, determine whether S_{a_i} S_{{a_i}+1} ... S_{b_i}, a substring of S, can be made into T_{c_i} T_{{c_i}+1} ... T_{d_i}, a substring of T.

-----Constraints-----
 - 1 \leq |S|, |T| \leq 10^5
 - S and T consist of letters A and B.
 - 1 \leq q \leq 10^5
 - 1 \leq a_i \leq b_i \leq |S|
 - 1 \leq c_i \leq d_i \leq |T|

-----Input-----
Input is given from Standard Input in the following format:
S
T
q
a_1 b_1 c_1 d_1
...
a_q b_q c_q d_q

-----Output-----
Print q lines. The i-th line should contain the response to the i-th query. If S_{a_i} S_{{a_i}+1} ... S_{b_i} can be made into T_{c_i} T_{{c_i}+1} ... T_{d_i}, print YES. Otherwise, print NO.

-----Sample Input-----
BBBAAAABA
BBBBA
4
7 9 2 5
7 9 1 4
1 7 2 5
1 7 2 4

-----Sample Output-----
YES
NO
YES
NO

The first query asks whether the string ABA can be made into BBBA.
As explained in the problem statement, it can be done by the first operation.
The second query asks whether ABA can be made into BBBB, and the fourth query asks whether BBBAAAA can be made into BBB.
Neither is possible.
The third query asks whether the string BBBAAAA can be made into BBBA.
As explained in the problem statement, it can be done by the second operation.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# -*- coding: utf-8 -*-\n\n#############\n# Libraries #\n#############\n\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\n\nimport math\n#from math import gcd\nimport bisect\nimport heapq\nfrom collections import defaultdict\nfrom collections import deque\nfrom collections import Counter\nfrom functools import lru_cache\n\n#############\n# Constants #\n#############\n\nMOD = 10**9+7\nINF = float(\'inf\')\nAZ = "abcdefghijklmnopqrstuvwxyz"\n\n#############\n# Functions #\n#############\n\n######INPUT######\ndef I(): return int(input().strip())\ndef S(): return input().strip()\ndef IL(): return list(map(int,input().split()))\ndef SL(): return list(map(str,input().split()))\ndef ILs(n): return list(int(input()) for _ in range(n))\ndef SLs(n): return list(input().strip() for _ in range(n))\ndef ILL(n): return [list(map(int, input().split())) for _ in range(n)]\ndef SLL(n): return [list(map(str, input().split())) for _ in range(n)]\n\n\n#####Shorten#####\ndef DD(arg): return defaultdict(arg)\n\n#####Inverse#####\ndef inv(n): return pow(n, MOD-2, MOD)\n\n######Combination######\nkaijo_memo = []\ndef kaijo(n):\n  if(len(kaijo_memo) > n): return kaijo_memo[n]\n  if(len(kaijo_memo) == 0): kaijo_memo.append(1)\n  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)\n  return kaijo_memo[n]\n\ngyaku_kaijo_memo = []\ndef gyaku_kaijo(n):\n  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]\n  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)\n  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)\n  return gyaku_kaijo_memo[n]\n\ndef nCr(n,r):\n  if n == r: return 1\n  if n < r or r < 0: return 0\n  ret = 1\n  ret = ret * kaijo(n) % MOD\n  ret = ret * gyaku_kaijo(r) % MOD\n  ret = ret * gyaku_kaijo(n-r) % MOD\n  return ret\n\n######Factorization######\ndef factorization(n):\n  arr = []\n  temp = n\n  for i in range(2, int(-(-n**0.5//1))+1):\n    if temp%i==0:\n      cnt=0\n      while temp%i==0: \n        cnt+=1 \n        temp //= i\n      arr.append([i, cnt])\n  if temp!=1: arr.append([temp, 1])\n  if arr==[]: arr.append([n, 1])\n  return arr\n\n#####MakeDivisors######\ndef make_divisors(n):\n  divisors = []\n  for i in range(1, int(n**0.5)+1):\n    if n % i == 0:\n      divisors.append(i)\n      if i != n // i: \n        divisors.append(n//i)\n  return divisors\n\n#####MakePrimes######\ndef make_primes(N):\n  max = int(math.sqrt(N))\n  seachList = [i for i in range(2,N+1)]\n  primeNum = []\n  while seachList[0] <= max:\n    primeNum.append(seachList[0])\n    tmp = seachList[0]\n    seachList = [i for i in seachList if i % tmp != 0]\n  primeNum.extend(seachList)\n  return primeNum\n\n#####GCD#####\ndef gcd(a, b):\n    while b: a, b = b, a % b\n    return a\n\n#####LCM#####\ndef lcm(a, b):\n    return a * b // gcd (a, b)\n\n#####BitCount#####\ndef count_bit(n):\n  count = 0\n  while n:\n    n &= n-1\n    count += 1\n  return count\n\n#####ChangeBase#####\ndef base_10_to_n(X, n):\n  if X//n: return base_10_to_n(X//n, n)+[X%n]\n  return [X%n]\n\ndef base_n_to_10(X, n):\n  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))\n\ndef base_10_to_n_without_0(X, n):\n  X -= 1\n  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]\n  return [X%n]\n\n#####IntLog#####\ndef int_log(a, n):\n  count = 0\n  while n>=a:\n    n //= a\n    count += 1\n  return count\n\n#############\n# Main Code #\n#############\n\nS = input().strip()\nT = input().strip()\n\naccS = [0]\nfor s in S:\n  if s == "A":\n    accS.append((accS[-1]+1)%3)\n  else:\n    accS.append((accS[-1]+2)%3)\naccT = [0]\nfor t in T:\n  if t == "A":\n    accT.append((accT[-1]+1)%3)\n  else:\n    accT.append((accT[-1]+2)%3)\n\nQ = I()\nfor _ in range(Q):\n  a,b,c,d = IL()\n  if ((accS[b]-accS[a-1]) - (accT[d]-accT[c-1])) %3:\n    print("NO")\n  else:\n    print("YES")'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 17921