#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
const int md = 1e9 + 7;
const double EPS = 1e-15;
string a, b;
int q;
int l, r, ll, rr;
int cnt[N];
int cnta[N];
int cnt1[N];
int cnt1a[N];
int lastc[N];
int last1c[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> a;
  for (int i = 0; i < int(a.size()); i++) {
    cnt[i + 1] = cnt[i];
    if (a[i] != 'A') cnt[i + 1]++;
    if (a[i] == 'A')
      lastc[i + 1] = lastc[i] + 1;
    else
      lastc[i + 1] = 0;
  }
  cin >> b;
  for (int i = 0; i < int(b.size()); i++) {
    cnt1[i + 1] = cnt1[i];
    if (b[i] != 'A') cnt1[i + 1]++;
    if (b[i] == 'A')
      last1c[i + 1] = last1c[i] + 1;
    else
      last1c[i + 1] = 0;
  }
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> l >> r >> ll >> rr;
    int x = cnt[r] - cnt[l - 1];
    int y = cnt1[rr] - cnt1[ll - 1];
    int first = min(r - l + 1, lastc[r]);
    int s = min(rr - ll + 1, last1c[rr]);
    if (x % 2 == y % 2 && x <= y &&
        (first > s || (first >= s && (x > 0 || x == y))) &&
        (first % 3 == s % 3 || x < y))
      cout << 1;
    else
      cout << 0;
  }
  return 0;
}
