#include <bits/stdc++.h>
using namespace std;
const long long max_n = 200011;
int sum_bc[2][max_n], n, cnt_a[2][max_n];
string s[2];
int get_sum(int ind, int l, int r) {
  int ans = sum_bc[ind][r];
  if (l) ans -= sum_bc[ind][l - 1];
  return ans;
}
bool query_result(int l0, int r0, int l1, int r1) {
  int sum0 = get_sum(0, l0, r0);
  int sum1 = get_sum(1, l1, r1);
  int cnt0 = min(r0 - l0 + 1, cnt_a[0][r0]);
  int cnt1 = min(r1 - l1 + 1, cnt_a[1][r1]);
  if ((sum0 + sum1) % 2) return false;
  if (sum0 > sum1) return false;
  if (cnt1 > cnt0) return false;
  if (sum0 == sum1) {
    return (cnt1 - cnt0) % 3 == 0;
  }
  if (cnt0 > cnt1) return true;
  return sum0 != 0;
}
void get_sum_bc() {
  for (int i = 0; i < 2; ++i) {
    for (int q = 0; q < s[i].length(); ++q) {
      if (s[i][q] != 'A') {
        sum_bc[i][q] = 1;
        cnt_a[i][q] = 0;
      } else {
        cnt_a[i][q] = 1;
        if (q) cnt_a[i][q] += cnt_a[i][q - 1];
      }
      if (q) {
        sum_bc[i][q] += sum_bc[i][q - 1];
      }
    }
  }
}
int main() {
  cin >> s[0] >> s[1] >> n;
  get_sum_bc();
  int a, b, c, d;
  while (n--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    --a;
    --b;
    --c;
    --d;
    int ans = query_result(a, b, c, d);
    printf("%d", ans);
  }
  return 0;
}
