#include <bits/stdc++.h>
using namespace std;
int suf1[100001];
int suf2[100001];
int cum1[100001];
int cum2[100001];
pair<int, int> trailing(int l1, int r1, int l2, int r2) {
  int t1, t2;
  if (r1 - suf1[r1 - 1] >= l1)
    t1 = suf1[r1 - 1];
  else
    t1 = suf1[r1 - 1] - suf1[l1 - 1] + 1;
  if (r2 - suf2[r2 - 1] >= l2)
    t2 = suf2[r2 - 1];
  else
    t2 = suf2[r2 - 1] - suf2[l2 - 1] + 1;
  return {t1, t2};
}
pair<int, int> cum(int l1, int r1, int l2, int r2) {
  return {(cum1[r1 - 1] - (l1 == 1 ? 0 : cum1[l1 - 2])),
          (cum2[r2 - 1] - (l2 == 1 ? 0 : cum2[l2 - 2]))};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    if (i) cum1[i] += cum1[i - 1];
    cum1[i] += (a[i] != 'A' ? 1 : 0);
    if (a[i] == 'A') {
      suf1[i] += 1;
      if (i) suf1[i] += suf1[i - 1];
    }
  }
  for (int i = 0; i < b.size(); i++) {
    if (i) cum2[i] += cum2[i - 1];
    cum2[i] += (b[i] != 'A' ? 1 : 0);
    if (b[i] == 'A') {
      suf2[i] += 1;
      if (i) suf2[i] += suf2[i - 1];
    }
  }
  int q;
  cin >> q;
  int l1, l2, r1, r2;
  for (int i = 0; i < q; i++) {
    cin >> l1 >> r1 >> l2 >> r2;
    pair<int, int> tr = trailing(l1, r1, l2, r2);
    pair<int, int> cc = cum(l1, r1, l2, r2);
    bool ok = 1;
    if (tr.second > tr.first) ok = 0;
    tr.first -= tr.second;
    if ((tr.first) % 3 || (tr.first && !cc.first && cc.second)) cc.first += 2;
    if (cc.first > cc.second) ok = 0;
    if (((cc.second - cc.first) & 1) || (cc.second && !cc.first)) ok = 0;
    cout << ok;
  }
}
