#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int maxn = 2e5 + 7;
char S[maxn], T[maxn];
int Q, a, b, c, d;
int sumS[maxn], sumT[maxn];
int lastS[maxn], lastT[maxn];
int main() {
  scanf(" %s %s %d", S, T, &Q);
  for (int i = 0; S[i]; ++i) {
    sumS[i + 1] = sumS[i] + (S[i] == 'C' || S[i] == 'B');
    lastS[i + 1] = lastS[i];
    if (S[i] == 'B' || S[i] == 'C') lastS[i + 1] = i + 1;
  }
  for (int i = 0; T[i]; ++i) {
    sumT[i + 1] = sumT[i] + (T[i] == 'C' || T[i] == 'B');
    lastT[i + 1] = lastT[i];
    if (T[i] == 'B' || T[i] == 'C') lastT[i + 1] = i + 1;
  }
  while (Q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int delta = sumT[d] - sumS[b] + sumS[a - 1] - sumT[c - 1];
    int delta2 = b - max(a - 1, lastS[b]) - (d - max(c - 1, lastT[d]));
    if (delta < 0 || delta % 2 != 0 || delta2 < 0 ||
        delta2 == 0 && !(sumS[b] - sumS[a - 1]) && delta > 0) {
      putchar('0');
      continue;
    }
    if (delta2 == 0 || delta > 0 || delta2 % 3 == 0)
      putchar('1');
    else
      putchar('0');
  }
  return 0;
}
