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>
using namespace std;
long long int pre[100005], arr[100005], t2[100005], t3[100005];
long long int pre2[100005], arr2[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n, m, i, j, k, a, b, c, d, xc = 0, xc2 = 0, a1 = 0, a2 = 0,
                                           t = 0;
  string str, str2, s1, s2;
  cin >> str >> str2;
  c = 0;
  for (i = 0; i < str.size(); i++) {
    if (str[i] == 'A') {
      arr[i + 1] = 1;
      arr[i + 1] += arr[i];
      if (t2[i])
        t2[i + 1] = t2[i];
      else {
        c++;
        t2[i + 1] = c;
      }
    } else {
      pre[i + 1] = 1;
    }
    pre[i + 1] += pre[i];
  }
  c = 0;
  for (i = 0; i < str2.size(); i++) {
    if (str2[i] == 'A') {
      arr2[i + 1] = 1;
      arr2[i + 1] += arr2[i];
      if (t3[i])
        t3[i + 1] = t3[i];
      else {
        c++;
        t3[i + 1] = c;
      }
    } else {
      pre2[i + 1] = 1;
    }
    pre2[i + 1] += pre2[i];
  }
  cin >> m;
  while (m--) {
    cin >> a >> b >> c >> d;
    if (t2[b] != t2[a - 1])
      a1 = arr[b];
    else
      a1 = arr[b] - arr[a - 1];
    xc = pre[b] - pre[a - 1];
    if (t3[d] != t3[c - 1])
      a2 = arr2[d];
    else
      a2 = arr2[d] - arr2[c - 1];
    xc2 = pre2[d] - pre2[c - 1];
    if (xc > xc2)
      cout << "0";
    else if (xc == xc2 && a1 < a2)
      cout << "0";
    else if (xc == xc2 && (a1 - a2) % 3)
      cout << "0";
    else if ((xc2 - xc) % 2)
      cout << "0";
    else {
      if (xc == xc2)
        cout << "1";
      else if (a1 < a2)
        cout << "0";
      else if (a1 - a2 >= 1)
        cout << "1";
      else if (xc)
        cout << "1";
      else
        cout << "0";
    }
  }
}
