#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
char s[MAXN], t[MAXN];
int cnts[MAXN], cntt[MAXN], coss[MAXN], cost[MAXN];
int main() {
  scanf("%s%s", s + 1, t + 1);
  for (int i = 1; s[i]; i++) {
    cnts[i] = cnts[i - 1] + (s[i] == 'A');
    if (s[i] == 'A')
      coss[i] = coss[i - 1] + 1;
    else
      coss[i] = 0;
  }
  for (int i = 1; t[i]; i++) {
    cntt[i] = cntt[i - 1] + (t[i] == 'A');
    if (t[i] == 'A')
      cost[i] = cost[i - 1] + 1;
    else
      cost[i] = 0;
  }
  int q;
  scanf("%d", &q);
  int l1, r1, l2, r2;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
    int ln1 = r1 - l1 + 1 - cnts[r1] + cnts[l1 - 1];
    int ln2 = r2 - l2 + 1 - cntt[r2] + cntt[l2 - 1];
    int x = min(r1 - l1 + 1, coss[r1]), y = min(r2 - l2 + 1, cost[r2]);
    if (x == r1 - l1 + 1 && y < r2 - l2 + 1) {
      if (x > y)
        x = y;
      else
        x--;
      ln1 += 2;
    }
    if (x < y) {
      printf("0");
      continue;
    }
    if ((x - y) % 3 != 0) ln1 += 2;
    if (ln1 <= ln2 && (ln1 - ln2) % 2 == 0)
      printf("1");
    else
      printf("0");
  }
  printf("\n");
}
