#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
const int N = 1e5 + 4;
int q;
void cal(const string &s, vector<int> &pre, vector<int> &near) {
  pre.assign(((int)(s).size()) + 1, 0);
  near.assign(((int)(s).size()) + 1, 0);
  for (int i = (1); i <= (((int)(s).size())); ++i) {
    pre[i] = pre[i - 1];
    if (s[i - 1] == 'B')
      near[i] = i, pre[i]++;
    else
      near[i] = near[i - 1];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, t;
  vector<int> preS, nearS, preT, nearT;
  cin >> s >> t;
  for (int i = (0); i <= (((int)(s).size()) - 1); ++i)
    if (s[i] == 'C') s[i] = 'B';
  for (int i = (0); i <= (((int)(t).size()) - 1); ++i)
    if (t[i] == 'C') t[i] = 'B';
  cal(s, preS, nearS);
  cal(t, preT, nearT);
  cin >> q;
  while (q--) {
    int l, r, l1, r1;
    cin >> l >> r >> l1 >> r1;
    int numS = preS[r] - preS[l - 1], cntS = r - max(l - 1, nearS[r]);
    int numT = preT[r1] - preT[l1 - 1], cntT = r1 - max(l1 - 1, nearT[r1]);
    if ((numS + numT) % 2 == 1 || numS > numT || cntS < cntT)
      cout << 0;
    else {
      if (numS == numT) {
        if (cntS != cntT && (cntS % 3 != cntT % 3))
          cout << 0;
        else
          cout << 1;
      } else {
        if (numS == 0 && cntS == cntT)
          cout << 0;
        else
          cout << 1;
      }
    }
  }
  return 0;
}
