#include <bits/stdc++.h>
const int N = 1e5 + 7;
char s[N], t[N];
int n, m, sa[N], sb[N], ta[N], tb[N];
inline int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x;
}
int main() {
  std::cin >> (s + 1) >> (t + 1);
  n = strlen(s + 1), m = strlen(t + 1);
  for (int i = 1; i <= n; ++i) {
    sb[i] = sb[i - 1];
    if (s[i] == 'A')
      sa[i] = sa[i - 1] + 1;
    else
      ++sb[i];
  }
  for (int i = 1; i <= m; ++i) {
    tb[i] = tb[i - 1];
    if (t[i] == 'A')
      ta[i] = ta[i - 1] + 1;
    else
      ++tb[i];
  }
  int q;
  std::cin >> q;
  while (q-- > 0) {
    int a = read(), b = read(), c = read(), d = read(), ans = 1;
    int db = tb[d] - tb[c - 1] - sb[b] + sb[a - 1];
    int Sa = std::min(b - a + 1, sa[b]), Ta = std::min(d - c + 1, ta[d]);
    if (db < 0 || Sa < Ta || db % 2 == 1) ans = 0;
    bool pd = (Sa - Ta) % 3 > 0;
    if (db - pd * 2 < 0) ans = 0;
    if (sb[b] - sb[a - 1] == 0 && db && Sa == Ta) ans = 0;
    printf("%d", ans);
  }
  return 0;
}
