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;
const int N = 100100;
char s[N], t[N], ans[N];
int Q;
struct SegT {
  int sum, pos;
} T1[N << 2], T2[N << 2];
SegT operator+(const SegT& a, const SegT& b) {
  SegT tmp;
  tmp.sum = a.sum + b.sum;
  tmp.pos = max(a.pos, b.pos);
  return tmp;
}
void Build(SegT* T, char* s, int x, int l, int r) {
  if (l == r) {
    if (s[l] == 'B' || s[l] == 'C')
      T[x].sum = 1, T[x].pos = l;
    else
      T[x].sum = 0, T[x].pos = -1;
    return;
  }
  int mid = l + r >> 1;
  Build(T, s, (x << 1), l, mid);
  Build(T, s, (x << 1 | 1), mid + 1, r);
  T[x] = T[(x << 1)] + T[(x << 1 | 1)];
  return;
}
SegT Query(SegT* T, int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return T[x];
  int mid = l + r >> 1;
  if (R <= mid)
    return Query(T, (x << 1), l, mid, L, R);
  else if (L > mid)
    return Query(T, (x << 1 | 1), mid + 1, r, L, R);
  return Query(T, (x << 1), l, mid, L, R) +
         Query(T, (x << 1 | 1), mid + 1, r, L, R);
}
int main() {
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  scanf("%d", &Q);
  int l1, r1, l2, r2, n = strlen(s + 1), m = strlen(t + 1);
  SegT a1, a2;
  Build(T1, s, 1, 1, n);
  Build(T2, t, 1, 1, m);
  int cnt = 0, rlen1, rlen2, cnt1, cnt2, ff, cnt01, cnt02;
  while (Q--) {
    scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
    a1 = Query(T1, 1, 1, n, l1, r1);
    a2 = Query(T2, 1, 1, m, l2, r2);
    rlen1 = r1 - l1 + 1, rlen2 = r2 - l2 + 1;
    if (a1.pos > 0) rlen1 = r1 - a1.pos;
    if (a2.pos > 0) rlen2 = r2 - a2.pos;
    cnt1 = a1.sum;
    cnt2 = a2.sum;
    ff = 0;
    if (rlen1 < rlen2) {
      ans[++cnt] = '0';
      continue;
    }
    if (cnt1 > cnt2) {
      ans[++cnt] = '0';
      continue;
    }
    if ((cnt2 - cnt1) & 1) {
      ans[++cnt] = '0';
      continue;
    }
    if (rlen1 > rlen2) {
      if (cnt2 > cnt1 || (rlen1 - rlen2) % 3 == 0) ff = 1;
    } else {
      if (cnt1 > 0 || (cnt1 == 0 && cnt2 == 0)) ff = 1;
    }
    ans[++cnt] = ff + '0';
  }
  ans[++cnt] = '\0';
  printf("%s", ans + 1);
  return 0;
}
