#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5, INF = 0x3f3f3f3f;
int sum[M], sum1[M];
int Sa[M], Ta[M];
char A[M], B[M];
int main() {
  scanf("%s%s", A + 1, B + 1);
  int n = strlen(A + 1), m = strlen(B + 1);
  for (int j = 1; j <= n; j++) {
    if (A[j] == 'A') {
      Sa[j] = Sa[j - 1] + 1;
      sum[j] = sum[j - 1];
    } else {
      Sa[j] = 0;
      sum[j] = sum[j - 1] + 1;
    }
  }
  for (int j = 1; j <= m; j++) {
    if (B[j] == 'A') {
      Ta[j] = Ta[j - 1] + 1;
      sum1[j] = sum1[j - 1];
    } else {
      Ta[j] = 0;
      sum1[j] = sum1[j - 1] + 1;
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int x = (sum[b] - sum[a - 1]) & 1, y = (sum1[d] - sum1[c - 1]) & 1;
    int Sb = (sum[b] - sum[a - 1]), Tb = (sum1[d] - sum1[c - 1]);
    int SA = min(Sa[b], b - a + 1), TA = min(Ta[d], d - c + 1);
    if ((SA - TA) % 3) Sb += 2;
    if (Sb > Tb || SA < TA)
      printf("0");
    else if (SA == TA && Sb == 0 && Tb)
      printf("0");
    else if (x == y)
      printf("1");
    else
      printf("0");
  }
  printf("\n");
  return 0;
}
