#include <bits/stdc++.h>
using namespace std;
string s, t;
const int N = 100000 + 10;
int q, a, b, c, d, sa[N], ta[N], sb[N], tb[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> t >> q;
  for (int i = 0; i < s.length(); i++) {
    sa[i + 1] = sa[i] + (s[i] != 'A');
    sb[i + 1] = (s[i] == 'A') * (sb[i] + 1);
  }
  for (int i = 0; i < t.length(); i++) {
    ta[i + 1] = ta[i] + (t[i] != 'A');
    tb[i + 1] = (t[i] == 'A') * (tb[i] + 1);
  }
  while (q--) {
    cin >> a >> b >> c >> d;
    if (((ta[d] - ta[c - 1]) & 1) != ((sa[b] - sa[a - 1]) & 1)) {
      cout << '0';
    } else if (ta[d] - ta[c - 1] == sa[b] - sa[a - 1] &&
               (min(tb[d], d - c + 1) > min(sb[b], b - a + 1) ||
                (min(sb[b], b - a + 1) - min(tb[d], d - c + 1)) % 3)) {
      cout << '0';
    } else if (ta[d] - ta[c - 1] > sa[b] - sa[a - 1] &&
               sa[b] - sa[a - 1] != 0 &&
               min(tb[d], d - c + 1) > min(sb[b], b - a + 1)) {
      cout << '0';
    } else if (ta[d] - ta[c - 1] > sa[b] - sa[a - 1] &&
               sa[b] - sa[a - 1] == 0 &&
               min(tb[d], d - c + 1) >= min(sb[b], b - a + 1)) {
      cout << '0';
    } else if (ta[d] - ta[c - 1] < sa[b] - sa[a - 1]) {
      cout << '0';
    } else {
      cout << '1';
    }
  }
}
