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 <image> BC
  * B <image> AC
  * C <image> AB
  * AAA <image> 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.

Input

The first line contains a string S (1 ≤ |S| ≤ 105). The second line contains a string T (1 ≤ |T| ≤ 105), 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 ≤ 105).

The following Q lines describe queries. The i-th of these lines contains four space separated integers ai, bi, ci, di. These represent the i-th query: is it possible to create T[ci..di] from S[ai..bi] 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|.

Output

Print a string of Q characters, where the i-th character is '1' if the answer to the i-th query is positive, and '0' otherwise.

Example

Input

AABCCBAAB
ABCB
5
1 3 1 2
2 2 2 4
7 9 1 1
3 4 2 3
4 5 1 3


Output

10011

Note

In the first query we can achieve the result, for instance, by using transitions <image>.

The third query asks for changing AAB to A — but in this case we are not able to get rid of the character 'B'.
#include <bits/stdc++.h>
const int maxn = 100005;
int Q, L, R, A_lstA[maxn], A_totBC[maxn], B_lstA[maxn], B_totBC[maxn], _A_lstA_,
    _A_totBC_, _B_lstA_, _B_totBC_;
char A[maxn], B[maxn];
inline void read(int &Res) {
  char ch = getchar();
  for (Res = 0; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); ch = getchar()) Res = (Res << 3) + (Res << 1) + ch - 48;
}
inline void Work() {
  for (int i = 1; A[i]; ++i)
    A_totBC[i] = A_totBC[i - 1] + (A[i] == 'B' || A[i] == 'C'),
    A_lstA[i] = A[i] == 'A' ? A_lstA[i - 1] + 1 : 0;
  for (int i = 1; B[i]; ++i)
    B_totBC[i] = B_totBC[i - 1] + (B[i] == 'B' || B[i] == 'C'),
    B_lstA[i] = B[i] == 'A' ? B_lstA[i - 1] + 1 : 0;
}
int main() {
  for (scanf("%s%s%d", A + 1, B + 1, &Q), Work(); Q; --Q) {
    read(L), read(R), _A_lstA_ = std::min(R - L + 1, A_lstA[R]),
                      _A_totBC_ = A_totBC[R] - A_totBC[L - 1];
    read(L), read(R), _B_lstA_ = std::min(R - L + 1, B_lstA[R]),
                      _B_totBC_ = B_totBC[R] - B_totBC[L - 1];
    if (_A_lstA_ < _B_lstA_ || _A_totBC_ > _B_totBC_ ||
        ((_A_totBC_ & 1) ^ (_B_totBC_ & 1)))
      putchar('0');
    else if ((_A_lstA_ > _B_lstA_ && _A_totBC_ < _B_totBC_) ||
             ((_A_totBC_ || !_B_totBC_) && (_A_lstA_ - _B_lstA_) % 3 == 0))
      putchar('1');
    else
      putchar('0');
  }
  return 0;
}
