#include <bits/stdc++.h>
using namespace std;
string S, T;
int Q;
int psum[2][100010], la[2][100010];
int calc(int t, int l, int r) { return psum[t][r] - (l ? psum[t][l - 1] : 0); }
char ans[100010];
int main() {
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++)
    if (S[i] == 'C') S[i] = 'B';
  for (int i = 0; i < T.size(); i++)
    if (T[i] == 'C') T[i] = 'B';
  for (int i = 0; i < S.size(); i++) {
    psum[0][i] = S[i] == 'B';
    if (i) psum[0][i] += psum[0][i - 1];
  }
  for (int i = 0; i < T.size(); i++) {
    psum[1][i] = T[i] == 'B';
    if (i) psum[1][i] += psum[1][i - 1];
  }
  for (int i = 0; i < S.size(); i++) {
    la[0][i] = -1;
    if (i) la[0][i] = la[0][i - 1];
    if (S[i] == 'B') la[0][i] = i;
  }
  for (int i = 0; i < T.size(); i++) {
    la[1][i] = -1;
    if (i) la[1][i] = la[1][i - 1];
    if (T[i] == 'B') la[1][i] = i;
  }
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    a--;
    b--;
    c--;
    d--;
    int t1 = calc(0, a, b);
    int t2 = calc(1, c, d);
    if (t1 > t2 || t1 % 2 != t2 % 2) {
      ans[i] = '0';
      continue;
    }
    int s1 = min(b - a + 1, b - la[0][b]);
    int s2 = min(d - c + 1, d - la[1][d]);
    if (!t1 && t2 && s1 == s2) {
      ans[i] = '0';
      continue;
    }
    if (s1 >= s2 && s1 % 3 == s2 % 3) {
      ans[i] = '1';
    } else if (t1 < t2 && s1 > s2) {
      ans[i] = '1';
    } else
      ans[i] = '0';
  }
  for (int i = 0; i < Q; i++) {
    printf("%c", ans[i]);
  }
}
