#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   string ax, bx;   int q, pre1[MAXN], pre2[MAXN], pre3[MAXN], pre4[MAXN], a, b, c, d;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> ax >> bx >> q;     for (int i = 1; i <= ax.size(); ++i) {       if (ax[i - 1] ==  A ) {         pre1[i] = pre1[i - 1] + 1;         pre2[i] = pre2[i - 1];       } else {         pre1[i] = 0;         pre2[i] = pre2[i - 1] + 1;       }     }     for (int i = 1; i <= bx.size(); ++i) {       if (bx[i - 1] ==  A ) {         pre3[i] = pre3[i - 1] + 1;         pre4[i] = pre4[i - 1];       } else {         pre3[i] = 0;         pre4[i] = pre4[i - 1] + 1;       }     }     for (int i = 0; i < q; ++i) {       int xa, xb, ya, yb;       cin >> a >> b >> c >> d;       xa = min(pre1[b], b - a + 1);       ya = min(pre3[d], d - c + 1);       xb = pre2[b] - pre2[a - 1];       yb = pre4[d] - pre4[c - 1];       if (xa < ya || xb % 2 != yb % 2) {         cout << 0;         continue;       }       if (xa == ya && xb == 0 && yb != 0) {         cout << 0;         continue;       }       if (xa > ya && (xa - ya) % 3 != 0) {         xb += 2;       }       if (xb <= yb && (yb - xb) % 2 == 0)         cout << 1;       else         cout << 0;     }     cout <<   n ;   }   