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;
void qmax(int &x, int y) {
  if (x < y) x = y;
}
void qmin(int &x, int y) {
  if (x > y) x = y;
}
long long read() {
  char s;
  long long k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (isdigit(s)) {
    k = k * 10 + (s ^ '0');
    s = getchar();
  }
  return k * base;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    write(-x);
  } else {
    if (x / 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
const int maxn = 1e5 + 100;
char a[maxn];
char b[maxn];
int T, n, m;
int A, B, C, D;
int sa[maxn][4];
int sb[maxn][4];
int ne[maxn];
int n1[maxn];
int main() {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  T = read();
  for (int i = 1; i <= n; i++) sa[i][a[i] - 'A']++;
  for (int i = 1; i <= m; i++) sb[i][b[i] - 'A']++;
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] == 'A')
      ne[i] = ne[i - 1];
    else
      ne[i] = i - 1;
    if (a[i] != 'A') ne[i] = i;
    sa[i][1] += sa[i - 1][1];
    sa[i][2] += sa[i - 1][2];
    sa[i][0] = sa[i][1] + sa[i][2];
  }
  for (int i = 1; i <= m; i++) {
    if (b[i - 1] == 'A')
      n1[i] = n1[i - 1];
    else
      n1[i] = i - 1;
    if (b[i] != 'A') n1[i] = i;
    sb[i][1] += sb[i - 1][1];
    sb[i][2] += sb[i - 1][2];
    sb[i][0] = sb[i][1] + sb[i][2];
  }
  while (T--) {
    A = read();
    B = read();
    C = read();
    D = read();
    int s1, s2, Y;
    s1 = sa[B][0] - sa[A - 1][0];
    s2 = sb[D][0] - sb[C - 1][0];
    if (s1 > s2 || s1 % 2 != s2 % 2) {
      printf("0");
      continue;
    }
    if (s1 % 2 == s2 % 2) {
      int X = (B - ne[B]);
      X = min(X, B - A + 1);
      Y = min(D - n1[D], D - C + 1);
      if (s1 == 0 && X == Y && s2 != 0) {
        printf("0");
        continue;
      }
      if (X < Y) {
        printf("0");
        continue;
      }
      if (((X - Y) % 3 == 0) || s1 + 2 <= s2) {
        printf("1");
        continue;
      }
      printf("0");
    } else
      printf("0");
  }
  return 0;
}
