#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 62);
const int inf = (1 << 30);
const int nmax = 1e5 + 50;
const long long mod = 1e9 + 7;
using namespace std;
int n, i, j, nr[2][nmax], ls[2][nmax], a, b, c, d, q;
string st, rs;
char s[2][nmax];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  for (j = 0; j < 2; j++) {
    cin >> st;
    n = (int)st.size();
    for (i = 1; i <= n; i++) {
      s[j][i] = st[i - 1];
      if (s[j][i] == 'C') s[j][i] = 'B';
      nr[j][i] = nr[j][i - 1] + (s[j][i] == 'B');
      ls[j][i] = (s[j][i] == 'B' ? i : ls[j][i - 1]);
    }
  }
  cin >> q;
  while (q--) {
    cin >> a >> b >> c >> d;
    if (nr[0][b] - nr[0][a - 1] > nr[1][d] - nr[1][c - 1] ||
        (nr[1][d] - nr[1][c - 1] - nr[0][b] + nr[0][a - 1]) & 1)
      rs += '0';
    else if (nr[1][d] - nr[1][c - 1] == 0 && nr[0][b] - nr[0][a - 1] == 0) {
      if (b - a < d - c || (d - c - b + a) % 3)
        rs += '0';
      else
        rs += '1';
    } else if (nr[0][b] - nr[0][a - 1] == 0) {
      if (b - a + 1 > d - ls[1][d])
        rs += '1';
      else
        rs += '0';
    } else if (nr[0][b] - nr[0][a - 1] == nr[1][d] - nr[1][c - 1]) {
      if (b - ls[0][b] < d - ls[1][d] || (d - ls[1][d] - b + ls[0][b]) % 3)
        rs += '0';
      else
        rs += '1';
    } else {
      if (b - ls[0][b] < d - ls[1][d])
        rs += '0';
      else
        rs += '1';
    }
  }
  cout << rs << endl;
  return 0;
}
