#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
string s, t;
char c[N];
int cs[2][N], ct[2][N], q;
int main() {
  scanf(" %s", c);
  s = c;
  scanf(" %s", c);
  t = c;
  int at = 0;
  for (auto &i : s) {
    at++;
    if (i == 'C' || i == 'B') {
      i = 'B';
      cs[1][at] = cs[1][at - 1] + 1;
    } else {
      cs[1][at] = cs[1][at - 1];
      cs[0][at] = cs[0][at - 1] + 1;
    }
  }
  at = 0;
  for (auto &i : t) {
    at++;
    if (i == 'C' || i == 'B') {
      i = 'B';
      ct[1][at] = ct[1][at - 1] + 1;
    } else {
      ct[1][at] = ct[1][at - 1];
      ct[0][at] = ct[0][at - 1] + 1;
    }
  }
  scanf("%d", &q);
  for (int i = 0, a, b, c, d; i < q; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int difs = cs[1][b] - cs[1][a - 1];
    int dift = ct[1][d] - ct[1][c - 1];
    bool thereis = 0;
    int need = dift - difs;
    int trails = min(b - a + 1, cs[0][b]);
    int trailt = min(d - c + 1, ct[0][d]);
    if (need & 1) {
      printf("0");
      continue;
    }
    if (need < 0) {
      printf("0");
      continue;
    }
    if (!need) {
      if (trails < trailt || (trails - trailt) % 3) {
        printf("0");
        continue;
      }
      printf("1");
      continue;
    }
    if (need && trails > trailt) {
      trails = trailt;
      thereis = 1;
    }
    if ((trails - trailt) % 3 || trails < trailt) {
      printf("0");
      continue;
    }
    thereis |= difs;
    if (!thereis && need) {
      printf("0");
      continue;
    }
    printf("1");
  }
}
