#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int inf = (1 << 30) - 1;
const int N = (int)5e5 + 5;
int n, m, q, bs[N], bt[N], lbs[N], lbt[N];
char t[N], second[N];
int main() {
  scanf("%s", second + 1);
  n = strlen(second + 1);
  scanf("%s", t + 1);
  m = strlen(t + 1);
  int bb = 0;
  for (int i = 1; i <= n; i++) {
    bs[i] = bs[i - 1] + (second[i] != 'A');
    if (second[i] != 'A') bb = i;
    lbs[i] = bb;
  }
  bb = 0;
  for (int i = 1; i <= m; i++) {
    bt[i] = bt[i - 1] + (t[i] != 'A');
    if (t[i] != 'A') bb = i;
    lbt[i] = bb;
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r, L, R;
    scanf("%d %d %d %d", &l, &r, &L, &R);
    int sa = r - max(lbs[r], l - 1);
    int ta = R - max(lbt[R], L - 1);
    if (sa < ta) {
      putchar('0');
      continue;
    }
    int sb = bs[r] - bs[l - 1];
    int tb = bt[R] - bt[L - 1];
    if (tb == sb) {
      if (sa >= ta && (sa - ta) % 3 == 0) {
        putchar('1');
        continue;
      }
    }
    if (sa != ta) sb += 2;
    if (sb == 0 && tb == 0) {
      putchar('1');
      continue;
    }
    if (sb > 0 && sb <= tb && ((sb + tb) & 1) == 0) {
      putchar('1');
    } else {
      putchar('0');
    }
  }
  puts("");
  return 0;
}
