#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int prefA[2][maxn], prefB[2][maxn];
vector<int> posB[2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); ++i) {
    prefA[0][i + 1] = prefA[0][i];
    prefB[0][i + 1] = prefB[0][i];
    if (s[i] == 'A')
      prefA[0][i + 1]++;
    else
      prefB[0][i + 1]++, posB[0].push_back(i + 1);
  }
  for (int i = 0; i < t.size(); ++i) {
    prefA[1][i + 1] = prefA[1][i];
    prefB[1][i + 1] = prefB[1][i];
    if (t[i] == 'A')
      prefA[1][i + 1]++;
    else
      prefB[1][i + 1]++, posB[1].push_back(i + 1);
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cntB[2];
    cntB[0] = prefB[0][b] - prefB[0][a - 1];
    cntB[1] = prefB[1][d] - prefB[1][c - 1];
    if (cntB[0] > cntB[1] || ((cntB[1] - cntB[0]) & 1))
      cout << 0;
    else {
      int lastA[2] = {};
      int L = -1, R = posB[0].size();
      while (L + 1 < R) {
        int M = (L + R) / 2;
        if (posB[0][M] <= b)
          L = M;
        else
          R = M;
      }
      int pos;
      if (L == -1)
        pos = a - 1;
      else
        pos = max(posB[0][L], a - 1);
      lastA[0] = prefA[0][b] - prefA[0][pos];
      L = -1;
      R = posB[1].size();
      while (L + 1 < R) {
        int M = (L + R) / 2;
        if (posB[1][M] <= d)
          L = M;
        else
          R = M;
      }
      if (L == -1)
        pos = c - 1;
      else
        pos = max(posB[1][L], c - 1);
      lastA[1] = prefA[1][d] - prefA[1][pos];
      if (lastA[0] < lastA[1]) {
        cout << 0;
        continue;
      }
      if (cntB[0] == cntB[1]) {
        if ((lastA[0] - lastA[1]) % 3 == 0)
          cout << 1;
        else
          cout << 0;
      } else if (cntB[0] == 0) {
        if (lastA[0] != lastA[1])
          cout << 1;
        else
          cout << 0;
      } else {
        cout << 1;
      }
    }
  }
  return 0;
}
