#include <bits/stdc++.h>
using namespace std;
char st1[100010], st2[100010];
int a1[100010], a2[100010], b1[100010], b2[100010];
int n;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  scanf("%s%s", st1 + 1, st2 + 1);
  for (int i = 1; st1[i] != 0; i++) {
    if (st1[i] == 'A') a1[i] = a1[i - 1] + 1;
    b1[i] = b1[i - 1] + (st1[i] != 'A');
  }
  for (int i = 1; st2[i] != 0; i++) {
    if (st2[i] == 'A') a2[i] = a2[i - 1] + 1;
    b2[i] = b2[i - 1] + (st2[i] != 'A');
  }
  n = read();
  while (n--) {
    int l1 = read(), r1 = read(), l2 = read(), r2 = read(), ok = 1;
    int s1 = b1[r1] - b1[l1 - 1], s2 = b2[r2] - b2[l2 - 1];
    int x1 = min(r1 - l1 + 1, a1[r1]), x2 = min(r2 - l2 + 1, a2[r2]);
    if (s1 > s2 || (s1 + s2) % 2 == 1 || x1 < x2) ok = 0;
    if (s1 == s2 && x1 % 3 != x2 % 3 || s1 == 0 && x1 == x2 && s1 != s2) ok = 0;
    printf("%d", ok);
  }
}
