#include <bits/stdc++.h>
using namespace std;
int n, m, q, sum1[100005], sum2[100005], f1[100005], f2[100005];
char s[100005], t[100005];
signed main() {
  scanf("%s%s", s + 1, t + 1);
  n = strlen(s + 1);
  m = strlen(t + 1);
  for (register int i = 1; i <= n; i++) {
    sum1[i] = sum1[i - 1] + (s[i] != 'A');
    f1[i] = (s[i] == 'A') ? (f1[i - 1] + 1) : 0;
  }
  for (register int i = 1; i <= m; i++) {
    sum2[i] = sum2[i - 1] + (t[i] != 'A');
    f2[i] = (t[i] == 'A') ? (f2[i - 1] + 1) : 0;
  }
  scanf("%d", &q);
  while (q--) {
    int l, r, x, y;
    scanf("%d%d%d%d", &l, &r, &x, &y);
    int t1 = sum1[r] - sum1[l - 1], t2 = sum2[y] - sum2[x - 1];
    int g1 = min(f1[r], r - l + 1), g2 = min(f2[y], y - x + 1);
    if (t1 > t2 || (t2 - t1) & 1 || g2 > g1 || (t1 == t2 && (g2 - g1) % 3) ||
        (t1 == 0 && t2 != 0 && g1 == g2))
      putchar('0');
    else
      putchar('1');
  }
}
