#include <bits/stdc++.h>
using namespace std;
long long int pre[100005], arr[100005], t2[100005], t3[100005];
long long int pre2[100005], arr2[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n, m, i, j, k, a, b, c, d, xc = 0, xc2 = 0, a1 = 0, a2 = 0,
                                           t = 0;
  string str, str2, s1, s2;
  cin >> str >> str2;
  c = 0;
  for (i = 0; i < str.size(); i++) {
    if (str[i] == 'A') {
      arr[i + 1] = 1;
      arr[i + 1] += arr[i];
      if (t2[i])
        t2[i + 1] = t2[i];
      else {
        c++;
        t2[i + 1] = c;
      }
    } else {
      pre[i + 1] = 1;
    }
    pre[i + 1] += pre[i];
  }
  c = 0;
  for (i = 0; i < str2.size(); i++) {
    if (str2[i] == 'A') {
      arr2[i + 1] = 1;
      arr2[i + 1] += arr2[i];
      if (t3[i])
        t3[i + 1] = t3[i];
      else {
        c++;
        t3[i + 1] = c;
      }
    } else {
      pre2[i + 1] = 1;
    }
    pre2[i + 1] += pre2[i];
  }
  cin >> m;
  while (m--) {
    cin >> a >> b >> c >> d;
    if (t2[b] != t2[a - 1])
      a1 = arr[b];
    else
      a1 = arr[b] - arr[a - 1];
    xc = pre[b] - pre[a - 1];
    if (t3[d] != t3[c - 1])
      a2 = arr2[d];
    else
      a2 = arr2[d] - arr2[c - 1];
    xc2 = pre2[d] - pre2[c - 1];
    if (xc > xc2)
      cout << "0";
    else if (xc == xc2 && a1 < a2)
      cout << "0";
    else if (xc == xc2 && (a1 - a2) % 3)
      cout << "0";
    else if ((xc2 - xc) % 2)
      cout << "0";
    else {
      if (xc == xc2)
        cout << "1";
      else if (a1 < a2)
        cout << "0";
      else if (a1 - a2 >= 1)
        cout << "1";
      else if (xc)
        cout << "1";
      else
        cout << "0";
    }
  }
}
