#include <bits/stdc++.h>
using namespace std;
int main() {
  char S[100009], T[100009];
  int q, a, b, c, d, i, aa, bb, sa, sb, ta, tb, SA[100009], SB[100009],
      TA[100009], TB[100009];
  for (i = 1, SA[0] = SB[0] = TA[0] = TB[0] = 0,
      scanf("%s%s%d", S + 1, T + 1, &q);
       S[i]; ++i)
    SA[i] = S[i] == 'A' ? SA[i - 1] + 1 : 0, SB[i] = SB[i - 1] + (S[i] != 'A');
  for (i = 1; T[i]; ++i)
    TA[i] = T[i] == 'A' ? TA[i - 1] + 1 : 0, TB[i] = TB[i - 1] + (T[i] != 'A');
  while (q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d),
        sa = min(SA[b], b - a + 1), ta = min(TA[d], d - c + 1), aa = ta - sa,
        sb = SB[b] - SB[a - 1], tb = TB[d] - TB[c - 1], bb = tb - sb;
    if (1 & bb || bb < 0 || aa > 0 || tb && !sb && !aa)
      printf("0");
    else if (bb)
      printf("1");
    else if (aa % 3 == 0)
      printf("1");
    else
      printf("0");
  }
  exit(0);
}
