#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10;
char s[maxN], t[maxN];
int i, a[maxN], b[maxN], n, q, m, x, y, l, r, ans, ss[maxN], st[maxN],
    lass[maxN], last[maxN], s0, t0, s1, t1;
void Y() { printf("1"); }
void N() { printf("0"); }
int main() {
  scanf("%s\n", s + 1), n = strlen(s + 1);
  scanf("%s\n", t + 1), m = strlen(t + 1);
  for (i = 1; i <= n; i++) a[i] = (s[i] == 'A') ? 0 : 1;
  for (i = 1; i <= n; i++)
    ss[i] = ss[i - 1] + a[i], lass[i] = (a[i]) ? 0 : lass[i - 1] + 1;
  for (i = 1; i <= m; i++) b[i] = (t[i] == 'A') ? 0 : 1;
  for (i = 1; i <= m; i++)
    st[i] = st[i - 1] + b[i], last[i] = (b[i]) ? 0 : last[i - 1] + 1;
  for (scanf("%d", &q); q; q--) {
    scanf("%d%d%d%d", &x, &y, &l, &r);
    s0 = ((lass[y]) < (y - x + 1) ? (lass[y]) : (y - x + 1)),
    s1 = ss[y] - ss[x - 1],
    t0 = ((last[r]) < (r - l + 1) ? (last[r]) : (r - l + 1)),
    t1 = st[r] - st[l - 1];
    if (s1 > t1) {
      N();
      continue;
    }
    if (s0 < t0) {
      N();
      continue;
    }
    if ((s1 & 1) != (t1 & 1)) {
      N();
      continue;
    }
    if (s0 == t0) {
      if (t1 && !s1) {
        N();
        continue;
      }
    }
    if (s0 > t0) {
      if (s1 == t1 && (s0 - t0) % 3 != 0) {
        N();
        continue;
      }
    }
    Y();
  }
}
