#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
string S, T;
int Q, s[N], so[N], sz[N], t[N], to[N], tz[N];
int check(int os, int zs, int ot, int zt) {
  if (os == ot) {
    if (zs == zt) return 1;
    if (zs > zt && (zs - zt) % 3 == 0) return 1;
    return 0;
  }
  if (os > ot) return 0;
  if ((ot - os) % 2 != 0) return 0;
  if (os > 0 && zs == zt) return 1;
  if (zs > zt) return 1;
  return 0;
}
int main() {
  cin >> S >> T;
  for (int i = 1; i <= S.size(); i++) {
    if (S[i - 1] == 'A')
      s[i] = 0;
    else
      s[i] = 1;
    so[i] = so[i - 1] + s[i];
    sz[i] = s[i] ? 0 : sz[i - 1] + 1;
  }
  for (int i = 1; i <= T.size(); i++) {
    if (T[i - 1] == 'A')
      t[i] = 0;
    else
      t[i] = 1;
    to[i] = to[i - 1] + t[i];
    tz[i] = t[i] ? 0 : tz[i - 1] + 1;
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int os = so[b] - so[a - 1];
    int zs = sz[b] > b - a + 1 ? b - a + 1 : sz[b];
    int ot = to[d] - to[c - 1];
    int zt = tz[d] > d - c + 1 ? d - c + 1 : tz[d];
    cout << check(os, zs, ot, zt);
  }
  cout << endl;
  return 0;
}
