#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sum = 0, p = 1;
  char ch = getchar();
  while (!(('0' <= ch && ch <= '9') || ch == '-')) ch = getchar();
  if (ch == '-') p = -1, ch = getchar();
  while ('0' <= ch && ch <= '9') sum = sum * 10 + ch - 48, ch = getchar();
  return sum * p;
}
const int maxn = 1e5 + 20;
char s[maxn];
int n, m, a[maxn], b[maxn], pa[maxn], pb[maxn];
char p[maxn];
void init() {
  cin >> (s + 1);
  cin >> (p + 1);
  n = strlen(s + 1);
  m = strlen(p + 1);
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    a[i] = a[i - 1] + (s[i] == 'B') + (s[i] == 'C');
  for (int i = (1), _end_ = (m); i <= _end_; i++)
    b[i] = b[i - 1] + (p[i] == 'B') + (p[i] == 'C');
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    pa[i] = s[i] == 'A' ? pa[i - 1] + 1 : 0;
  for (int i = (1), _end_ = (m); i <= _end_; i++)
    pb[i] = p[i] == 'A' ? pb[i - 1] + 1 : 0;
}
inline void doing() {
  int q = read();
  for (int i = (1), _end_ = (q); i <= _end_; i++) {
    int l = read(), r = read();
    int l1 = read(), r1 = read();
    int x = a[r] - a[l - 1], y = b[r1] - b[l1 - 1];
    int Pa = min(pa[r], r - l + 1), Pb = min(pb[r1], r1 - l1 + 1);
    if (!x && y) {
      if (y % 2 == 0 && Pa - 1 >= Pb) {
        putchar('1');
        continue;
      } else {
        putchar('0');
        continue;
      }
    } else if (x <= y && (y - x) % 2 == 0 && Pa >= Pb &&
               (x < y || (Pa - Pb) % 3 == 0))
      putchar('1');
    else
      putchar('0');
  }
}
int main() {
  init();
  doing();
  return 0;
}
