#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x;
  char c;
  int f = 1;
  while ((c = getchar()) != '-' && (c > '9' || c < '0'))
    ;
  if (c == '-') c = getchar(), f = -1;
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ '0');
  return x * f;
}
inline long long readll() {
  long long x;
  char c;
  int f = 1;
  while ((c = getchar()) != '-' && (c > '9' || c < '0'))
    ;
  if (c == '-') c = getchar(), f = -1;
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 1ll) + (x << 3ll) + (c ^ '0');
  return x * f;
}
const int maxn = 1e5 + 10;
char s1[maxn], s2[maxn];
int a1[maxn], a2[maxn], b1[maxn], b2[maxn];
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  int n = strlen(s1 + 1), m = strlen(s2 + 1);
  for (register int i = 1, iend = n; i <= iend; ++i) {
    b1[i] = b1[i - 1];
    if (s1[i] == 'A')
      a1[i] = a1[i - 1] + 1;
    else
      b1[i]++, a1[i] = 0;
  }
  for (register int i = 1, iend = m; i <= iend; ++i) {
    b2[i] = b2[i - 1];
    if (s2[i] == 'A')
      a2[i] = a2[i - 1] + 1;
    else
      b2[i]++, a2[i] = 0;
  }
  int T = read();
  while (T--) {
    int l1 = read(), r1 = read(), l2 = read(), r2 = read();
    int u = b1[r1] - b1[l1 - 1], v = b2[r2] - b2[l2 - 1];
    int x = min(a1[r1], r1 - l1 + 1), y = min(a2[r2], r2 - l2 + 1);
    if ((u & 1) != (v & 1))
      putchar('0');
    else if (u > v)
      putchar('0');
    else if (x < y)
      putchar('0');
    else if (x % 3 != y % 3 && u + 2 > v)
      putchar('0');
    else if (x == y && x == r1 - l1 + 1 && y != r2 - l2 + 1)
      putchar('0');
    else
      putchar('1');
  }
  return 0;
}
