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;
char str1[100010], str2[100010];
int n1, n2, cuma1[100010], cumb1[100010], cumc1[100010];
int cuma2[100010], cumb2[100010], cumc2[100010];
bool ans[100010];
void input() {
  int i, j;
  scanf("%s", str1);
  scanf("%s", str2);
  n1 = strlen(str1);
  n2 = strlen(str2);
}
void pre() {
  int i, j;
  cumb1[n1] = cumc1[n1] = 0;
  for (i = n1 - 1; i >= 0; i--) {
    if (str1[i] == 'B') {
      cumb1[i] = cumb1[i + 1] + 1;
    } else {
      cumb1[i] = cumb1[i + 1];
    }
    if (str1[i] == 'C') {
      cumc1[i] = cumc1[i + 1] + 1;
    } else {
      cumc1[i] = cumc1[i + 1];
    }
  }
  cumb2[n2] = cumc2[n2] = 0;
  for (i = n2 - 1; i >= 0; i--) {
    if (str2[i] == 'B') {
      cumb2[i] = cumb2[i + 1] + 1;
    } else {
      cumb2[i] = cumb2[i + 1];
    }
    if (str2[i] == 'C') {
      cumc2[i] = cumc2[i + 1] + 1;
    } else {
      cumc2[i] = cumc2[i + 1];
    }
  }
  cuma1[0] = 0;
  for (i = 1; i < n1; i++) {
    if (str1[i] == 'B' || str1[i] == 'C') {
      cuma1[i] = i;
    } else {
      cuma1[i] = cuma1[i - 1];
    }
  }
  cuma2[0] = 0;
  for (i = 1; i < n2; i++) {
    if (str2[i] == 'B' || str2[i] == 'C') {
      cuma2[i] = i;
    } else {
      cuma2[i] = cuma2[i - 1];
    }
  }
}
int getA1(int l, int r) { return min(r - cuma1[r] + 1, r - l + 1); }
int getA2(int l, int r) { return min(r - cuma2[r] + 1, r - l + 1); }
int getB1(int l, int r) { return cumb1[l] - cumb1[r + 1]; }
int getB2(int l, int r) { return cumb2[l] - cumb2[r + 1]; }
int getC1(int l, int r) { return cumc1[l] - cumc1[r + 1]; }
int getC2(int l, int r) { return cumc2[l] - cumc2[r + 1]; }
void solve() {
  int i, j, q, l1, r1, l2, r2, bc1, bc2, a1, a2;
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &l1, &r1, &l2);
    scanf("%d", &r2);
    l1--;
    r1--;
    l2--;
    r2--;
    bc1 = getB1(l1, r1) + getC1(l1, r1);
    bc2 = getB2(l2, r2) + getC2(l2, r2);
    if (bc1 > bc2) {
      ans[i] = false;
      continue;
    }
    if ((bc2 - bc1) % 2 != 0) {
      ans[i] = false;
      continue;
    }
    a1 = getA1(l1, r1);
    a2 = getA2(l2, r2);
    if (a1 < a2) {
      ans[i] = false;
      continue;
    }
    if (a1 > a2) {
      if (a1 % 3 != a2 % 3) {
        if (bc2 - bc1 < 2) {
          ans[i] = false;
          continue;
        }
      }
    }
    ans[i] = true;
  }
  for (i = 0; i < q; i++) {
    printf("%d", ans[i]);
  }
  puts("");
}
int main() {
  input();
  pre();
  solve();
  return 0;
}
