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'.
AABCCBAAB
ABCB
5
1 3 1 2
2 2 2 4
7 9 1 1
3 4 2 3
4 5 1 3
10011
AAAAAA
AAAAAA
30
3 4 1 2
3 3 4 4
5 6 3 4
3 3 2 3
6 6 1 5
2 4 4 6
1 6 2 5
6 6 3 4
3 5 1 4
4 5 3 6
2 3 2 4
3 4 4 4
6 6 4 6
3 3 2 5
1 5 3 3
4 6 1 2
6 6 6 6
3 3 3 4
6 6 6 6
5 6 4 4
6 6 5 5
2 3 1 4
3 6 4 5
3 5 6 6
4 5 2 6
5 6 6 6
1 4 2 5
4 5 2 5
4 5 1 3
2 2 4 6
111001000000000010101000001000
A
A
1
1 1 1 1
1
CCBACACBCCCBBAAC
CACCAAABAACBBBBAC
20
7 7 2 15
3 11 14 15
4 9 6 12
10 15 13 17
10 16 5 14
14 15 12 16
16 16 16 16
3 15 9 14
10 12 8 12
15 15 9 10
14 15 8 15
7 14 17 17
15 15 17 17
15 15 5 9
4 14 12 17
13 15 8 12
1 4 2 2
6 13 17 17
11 14 5 11
15 16 2 9
00001100101000010000
ABAAAAAA
ABABBAAAAAA
5
3 8 4 11
3 8 3 11
2 8 2 11
1 8 1 11
1 8 2 11
00111
ABC
ABC
9
1 1 1 1
1 1 2 2
1 1 3 3
2 2 1 1
2 2 2 2
2 2 3 3
3 3 1 1
3 3 2 2
3 3 3 3
100011011
A
BB
1
1 1 1 2
1
BBAACCBACACBCCCBBAAC
CACCAAABAACBBBBACABC
1
3 10 6 13
0
AAAAACAAAAAB
AAAAABAAAAAC
20
1 6 10 12
10 12 7 12
9 12 8 12
2 6 8 12
7 12 2 6
9 12 7 12
1 6 10 12
4 6 3 6
7 12 7 12
4 6 5 6
3 6 12 12
5 6 8 12
9 12 1 6
2 6 3 6
10 12 2 6
1 6 12 12
7 12 3 6
9 12 3 6
10 12 10 12
11 12 11 12
11111111111111111111
AAABABACACACAAACAC
AABCBBACABACBBCBCC
20
6 17 17 17
14 17 13 14
1 13 7 12
11 17 5 17
6 10 16 17
16 17 16 16
15 17 17 17
15 15 7 10
1 4 10 14
4 11 2 17
6 9 1 7
16 16 11 18
4 14 6 17
1 17 6 18
13 18 15 18
1 12 5 11
8 8 12 17
10 15 3 7
17 17 9 14
6 17 6 6
00010001011111100110
AAACAABB
CACBCCBB
10
2 2 4 5
4 4 3 3
1 4 1 8
5 5 2 8
7 7 3 4
6 6 2 2
1 7 1 1
6 7 7 8
4 6 6 8
8 8 6 8
1111010011
A
CB
1
1 1 1 2
1
BCBBC
ABBCB
5
2 2 2 4
3 4 2 4
1 2 2 2
2 3 4 5
5 5 2 4
10011
a = input()
b = input()

l = [[0,0]]
c = [0,0]
for i in a:
    if i == 'A':
        c[0] += 1
    else:
        c[0] = 0
        c[1] += 1
    l.append([c[0],c[1]])
l1 = [[0,0]]
c = [0,0]
for i in b:
    if i == 'A':
        c[0] += 1
    else:
        c[0] = 0
        c[1] += 1
    l1.append([c[0],c[1]])
ans = ''
for _ in range(int(input())):
    a,b,c,d = map(int,input().split())
    x = l[b][1]-l[a-1][1]
    y = l1[d][1]-l1[c-1][1]
    if x > y or x % 2 != y % 2:
        ans += '0'
    else:
        m = min(l[b][0],b-a+1)
        n = min(l1[d][0],d-c+1)
        if m < n or m % 3 != n % 3 and x == y:
            ans += '0'
        else:
            ans += '1'
print(ans)