#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e6;
int cum_a_s[MAX_N];
int cum_a_t[MAX_N];
int cum_b_s[MAX_N];
int cum_b_t[MAX_N];
int l_t[MAX_N];
int l_s[MAX_N];
;
int main() {
  string s;
  cin >> s;
  s = " " + s;
  string t;
  cin >> t;
  t = " " + t;
  int cur = -1;
  for (int i = 1; i < s.size(); ++i) {
    cum_a_s[i] = cum_a_s[i - 1];
    cum_b_s[i] = cum_b_s[i - 1];
    if (s[i] != 'A')
      l_s[i] = (cur = i);
    else
      l_s[i] = cur;
    if (s[i] == 'A')
      cum_a_s[i]++;
    else
      cum_b_s[i]++;
  }
  cur = -1;
  for (int i = 1; i < t.size(); ++i) {
    cum_a_t[i] = cum_a_t[i - 1];
    cum_b_t[i] = cum_b_t[i - 1];
    if (t[i] != 'A')
      l_t[i] = (cur = i);
    else
      l_t[i] = cur;
    if (t[i] == 'A')
      cum_a_t[i]++;
    else
      cum_b_t[i]++;
  }
  int q;
  cin >> q;
  vector<int> ans;
  for (int i = 0; i < q; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt_b_s = cum_b_s[b] - cum_b_s[a - 1];
    int cnt_b_t = cum_b_t[d] - cum_b_t[c - 1];
    if (cnt_b_s > cnt_b_t || (cnt_b_t - cnt_b_s) % 2 == 1) {
      ans.push_back(0);
      continue;
    }
    int ls = l_s[b];
    int lt = l_t[d];
    int cnt_a_from_suff_s = 0;
    int cnt_a_from_suff_t = 0;
    if (ls >= a)
      cnt_a_from_suff_s = b - ls;
    else
      cnt_a_from_suff_s = b - a + 1;
    if (lt >= c)
      cnt_a_from_suff_t = d - lt;
    else
      cnt_a_from_suff_t = d - c + 1;
    if (cnt_a_from_suff_t > cnt_a_from_suff_s) {
      ans.push_back(0);
      continue;
    }
    if ((b - a + 1) - cnt_a_from_suff_s == 0 &&
        ((d - c + 1) - cnt_a_from_suff_t == 0)) {
      ans.push_back((abs(cnt_a_from_suff_s - cnt_a_from_suff_t) % 3 == 0));
      continue;
    }
    if ((b - a + 1) - cnt_a_from_suff_s == 0) {
      ans.push_back(cnt_a_from_suff_s > cnt_a_from_suff_t);
      continue;
    }
    if (cnt_b_s == cnt_b_t) {
      ans.push_back((abs(cnt_a_from_suff_s - cnt_a_from_suff_t) % 3 == 0));
      continue;
    }
    ans.push_back(1);
  }
  for (int i = 0; i < q; ++i) cout << ans[i];
}
