#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 20, inf = 2e9 + 20, mod = 1e9 + 7;
const string YN[] = {"NO", "YES"};
string s, t;
int ps[maxn], pt[maxn], prt[maxn], prs[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s >> t;
  s = 'A' + s;
  t = 'A' + t;
  int y = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (!i) continue;
    ps[i] = ps[i - 1] + (s[i] != 'A');
    if (s[i] != 'A') y = i;
    prs[i] = y;
  }
  y = 0;
  for (int i = 0; i < t.size(); ++i) {
    if (!i) continue;
    pt[i] = pt[i - 1] + (t[i] != 'A');
    if (t[i] != 'A') y = i;
    prt[i] = y;
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int Bs = (ps[b] - ps[a - 1]), Bt = (pt[d] - pt[c - 1]);
    int As = b - max(a - 1, prs[b]), At = d - max(c - 1, prt[d]);
    bool b1 = 1;
    if (Bs > Bt || (Bt - Bs) & 1) b1 = 0;
    if (At > As) b1 = 0;
    if ((Bs == Bt) && ((As - At) % 3)) b1 = 0;
    if (Bs == 0 && Bt > 0 && As == At) b1 = 0;
    cout << b1;
  }
  cout << endl;
  exit(0);
  ;
}
