#include <bits/stdc++.h>
using namespace std;
char s[100005];
int ls;
char t[100005];
int lt;
int cntas[100005];
int cntbs[100005];
int cntat[100005];
int cntbt[100005];
int q;
bool Check(int cbs, int cbt, int cas, int cat) {
  if (cbs == 0 && cbt > 0 && (cbt % 2) == 0) return cas > cat;
  if (cbs < cbt && (cbs % 2) == (cbt % 2) && cas >= cat) return true;
  if (cbs == cbt && cas >= cat && (cas % 3) == (cat % 3)) return true;
  return false;
}
int main() {
  scanf("%s%s%d", s + 1, t + 1, &q);
  ls = strlen(s + 1);
  lt = strlen(t + 1);
  for (int i = 1; i <= ls; ++i) {
    if (s[i] == 'A') cntas[i] = cntas[i - 1] + 1;
    cntbs[i] = cntbs[i - 1] + (s[i] != 'A');
  }
  for (int i = 1; i <= lt; ++i) {
    if (t[i] == 'A') cntat[i] = cntat[i - 1] + 1;
    cntbt[i] = cntbt[i - 1] + (t[i] != 'A');
  }
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    putchar('0' + Check(cntbs[b] - cntbs[a - 1], cntbt[d] - cntbt[c - 1],
                        min(b - a + 1, cntas[b]), min(d - c + 1, cntat[d])));
  }
  putchar('\n');
  return 0;
}
