#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 14;
int n, m;
struct S {
  string s;
  int n;
  int preA[maxn], cntB[maxn];
  void build() {
    for (auto &c : s)
      if (c == 'C') c = 'B';
    n = s.size();
    for (int i = 0; i < n; i++) cntB[i + 1] = cntB[i] + (s[i] == 'B');
    for (int i = 0; i < n; i++)
      if (s[i] == 'A') preA[i + 1] = 1 + preA[i];
  }
} s, p;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> s.s >> p.s;
  s.build();
  p.build();
  int q;
  cin >> q;
  while (q--) {
    int sl, sr, pl, pr;
    cin >> sl >> sr >> pl >> pr;
    sl--, pl--;
    int sb = s.cntB[sr] - s.cntB[sl];
    if (min(sr - sl, s.preA[sr]) % 3 != min(pr - pl, p.preA[pr]) % 3) sb += 2;
    if (min(sr - sl, s.preA[sr]) < min(pr - pl, p.preA[pr]) ||
        sb > p.cntB[pr] - p.cntB[pl] ||
        sb % 2 != (p.cntB[pr] - p.cntB[pl]) % 2 ||
        min(sr - sl, s.preA[sr]) == sr - sl &&
            sr - sl == min(pr - pl, p.preA[pr]) && sr - sl < pr - pl)
      cout << 0;
    else
      cout << 1;
  }
  cout << '\n';
}
