Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: 
 -  A <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> BC -  B <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> AC -  C <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> AB -  AAA <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> empty string 
Note that a substring is one or more consecutive characters. For given queries, determine whether it is possible to obtain the target string from source.
The first line contains a string *S* (1 ≤ |*S*| ≤ 10<sup class="upper-index">5</sup>). The second line contains a string *T* (1 ≤ |*T*| ≤ 10<sup class="upper-index">5</sup>), each of these strings consists only of uppercase English letters 'A', 'B' and 'C'.

The third line contains the number of queries *Q* (1 ≤ *Q* ≤ 10<sup class="upper-index">5</sup>).

The following *Q* lines describe queries. The *i*-th of these lines contains four space separated integers *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub>, *c*<sub class="lower-index">*i*</sub>, *d*<sub class="lower-index">*i*</sub>. These represent the *i*-th query: is it possible to create *T*[*c*<sub class="lower-index">*i*</sub>..*d*<sub class="lower-index">*i*</sub>] from *S*[*a*<sub class="lower-index">*i*</sub>..*b*<sub class="lower-index">*i*</sub>] by applying the above transitions finite amount of times?

Here, *U*[*x*..*y*] is a substring of *U* that begins at index *x* (indexed from 1) and ends at index *y*. In particular, *U*[1..|*U*|] is the whole string *U*.

It is guaranteed that 1 ≤ *a* ≤ *b* ≤ |*S*| and 1 ≤ *c* ≤ *d* ≤ |*T*|.
In the first query we can achieve the result, for instance, by using transitions <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/2c164f8b6e335aa51b97bbd019ca0d7326927314.png" style="max-width: 100.0%;max-height: 100.0%;"/>.

The third query asks for changing AAB to A — but in this case we are not able to get rid of the character 'B'.
s = input()
t = input()
l = [0 for i in range(len(s)+1)]
m = [0 for i in range(len(t)+1)]
c = 0
for i in range(1,len(s)+1):
    if s[i-1] == 'C' or s[i-1] == 'B':
        c += 1
    l[i] = c
c = 0
for i in range(1,len(t)+1):
    if t[i-1] == 'C' or t[i-1] == 'B':
        c += 1
    m[i] = c
n = int(input())
s = ''
for i in range(n):
    a,b,c,d = map(int, input().strip().split())
    q = l[b] - l[a-1]
    p = m[d] - m[c-1]
    if q%2 == p%2:
        s += '1'
    else:
        s += '0'
print (s)