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 long long INF = 0x3f3f3f3f3f3f3f3f;
const long long inf = 0xc0c0c0c0c0c0c0c0;
const double pi = acos(-1);
const int MAX = 1e5 + 7;
pair<int, int> tree[2][MAX << 2];
char in[MAX];
int lenA, lenB;
void w(pair<int, int> x) { printf("[B|C:%d A:%d]\n", x.first, x.second); }
pair<int, int> merge(pair<int, int> pl, pair<int, int> pr) {
  pair<int, int> ans = make_pair(pl.first + pr.first, pr.second);
  if (pr.first == 0) ans.second += pl.second;
  return ans;
}
void init(int l, int r, int pos, pair<int, int>* arr) {
  if (l == r) {
    if (in[l] == 'A')
      arr[pos] = make_pair(0, 1);
    else
      arr[pos] = make_pair(1, 0);
    return;
  }
  int mid = (l + r) >> 1;
  init(l, mid, pos << 1, arr);
  init(mid + 1, r, pos << 1 | 1, arr);
  arr[pos] = merge(arr[pos << 1], arr[pos << 1 | 1]);
}
pair<int, int> query(int from, int to, int l, int r, int pos,
                     pair<int, int>* arr) {
  if (from <= l && to >= r) return arr[pos];
  pair<int, int> ans = make_pair(0, 0);
  int mid = (l + r) >> 1;
  if (from <= mid) ans = merge(ans, query(from, to, l, mid, pos << 1, arr));
  if (mid < to)
    ans = merge(ans, query(from, to, mid + 1, r, pos << 1 | 1, arr));
  return ans;
}
int main() {
  scanf("%s", in);
  lenA = strlen(in);
  init(0, lenA, 1, tree[0]);
  scanf("%s", in);
  lenB = strlen(in);
  init(0, lenB, 1, tree[1]);
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    a--;
    b--;
    c--;
    d--;
    pair<int, int> x = query(a, b, 0, lenA, 1, tree[0]);
    pair<int, int> y = query(c, d, 0, lenB, 1, tree[1]);
    if (x.first > y.first)
      putchar('0');
    else if ((x.first ^ y.first) & 1)
      putchar('0');
    else if (x.second < y.second)
      putchar('0');
    else if (y.second < x.second && x.first < y.first)
      putchar('1');
    else if (x.second == y.second && x.first == 0 && y.first)
      putchar('0');
    else if ((x.second - y.second) % 3)
      putchar('0');
    else
      putchar('1');
  }
  return 0;
}
