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 s[2000000], s1[2000000];
int t[2000000], t1[2000000];
int n, m, T;
int f[2000000 * 2], g[2000000 * 2];
void build(char* S, int* f, int* t, int l, int r, int s) {
  if (l == r) {
    f[s] = (S[l] == 'B' || S[l] == 'C');
    if (!f[s]) t[s] = 1;
    return;
  }
  build(S, f, t, l, (l + r) / 2, s + s),
      build(S, f, t, (l + r) / 2 + 1, r, s + s + 1);
  f[s] = (f[s + s] + f[s + s + 1]);
  if (t[s + s + 1] == r - (l + r) / 2)
    t[s] = t[s + s + 1] + t[s + s];
  else
    t[s] = t[s + s + 1];
}
int get(int* f, int* t, int l, int r, int s, int ll, int rr, int& v) {
  if (r < ll || rr < l) return 0;
  if (ll <= l && r <= rr) {
    if (v == rr - r) v += t[s];
    return f[s];
  }
  int s1 = get(f, t, (l + r) / 2 + 1, r, s + s + 1, ll, rr, v);
  return s1 + get(f, t, l, (l + r) / 2, s + s, ll, rr, v);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  scanf("%s", s1 + 1);
  m = strlen(s1 + 1);
  build(s, f, t, 1, n, 1);
  build(s1, g, t1, 1, m, 1);
  scanf("%d", &T);
  while (T--) {
    int l, r, l1, r1;
    scanf("%d %d %d %d", &l, &r, &l1, &r1);
    int u1 = 0, u2 = 0;
    int v1 = get(f, t, 1, n, 1, l, r, u1), v2 = get(g, t1, 1, m, 1, l1, r1, u2);
    if (u2 > u1) {
      printf("0");
      continue;
    }
    if (!v1 && v2 && u1 == u2) {
      printf("0");
      continue;
    }
    u1 = (u1 - u2) % 3 + u2;
    if (u1 - u2) {
      v1 += 2;
      u1 = u2;
    }
    u1 %= 3, u2 %= 3;
    while (u1 != u2) (u1 += 1) %= 3, v1 += 2;
    v1 <= v2 && (v1 & 1) == (v2 & 1) ? printf("1") : printf("0");
  }
  return 0;
}
