#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N], t[N];
int a[N], b[N], aA[N], bA[N], m, l, r, L, R;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> (s + 1) >> (t + 1);
  for (int i = 1; s[i]; ++i)
    if (s[i] == 'A')
      a[i] = a[i - 1], aA[i] = aA[i - 1] + 1;
    else
      a[i] = a[i - 1] + 1;
  for (int i = 1; t[i]; ++i)
    if (t[i] == 'A')
      b[i] = b[i - 1], bA[i] = bA[i - 1] + 1;
    else
      b[i] = b[i - 1] + 1;
  for (cin >> m; m--;) {
    cin >> l >> r >> L >> R;
    int x = a[r] - a[l - 1], y = b[R] - b[L - 1];
    if (x > y || (y - x) % 2)
      cout.put('0');
    else {
      int sa = x ? aA[r] : r - l + 1, sb = y ? bA[R] : R - L + 1;
      if (x == y)
        cout.put('0' + (sa >= sb && (sa - sb) % 3 == 0));
      else
        cout.put('0' + (sa > sb || (sa == sb && x)));
    }
  }
  return 0;
}
