#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 5;
char s[MX], t[MX];
int sum1[MX], sum2[MX];
int pre1[MX], pre2[MX];
int main() {
  scanf("%s%s", s + 1, t + 1);
  int n = strlen(s + 1), m = strlen(t + 1);
  for (int i = 1; i <= n; i++) {
    sum1[i] = sum1[i - 1] + (s[i] != 'A');
    pre1[i] = s[i] == 'A' ? pre1[i - 1] + 1 : 0;
  }
  for (int i = 1; i <= m; i++) {
    sum2[i] = sum2[i - 1] + (t[i] != 'A');
    pre2[i] = t[i] == 'A' ? pre2[i - 1] + 1 : 0;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int x = sum2[d] - sum2[c - 1] - sum1[b] + sum1[a - 1];
    int y = min(b - a + 1, pre1[b]) - min(d - c + 1, pre2[d]);
    if (x < 0 || x % 2 == 1 || y < 0)
      printf("0");
    else if (y == 0) {
      if (x > 0 && sum1[b] - sum1[a - 1] == 0)
        printf("0");
      else
        printf("1");
    } else if (y > 0 && (x > 0 || y % 3 == 0))
      printf("1");
    else
      printf("0");
  }
  return 0;
}
