#include <bits/stdc++.h>
using namespace std;
int sa[100060], sb[100060], ta[100060], tb[100060];
char s[100060], t[100060], ara[100070];
int main() {
  int q;
  scanf("%s%s", s + 1, t + 1);
  int ns = strlen(s + 1);
  int nt = strlen(t + 1);
  for (int i = 1; i <= ns; i++) {
    if (s[i] == 'A')
      sa[i] = sa[i - 1] + 1, sb[i] = sb[i - 1];
    else
      sa[i] = 0, sb[i] = sb[i - 1] + 1;
  }
  for (int i = 1; i <= nt; i++) {
    if (t[i] == 'A')
      ta[i] = ta[i - 1] + 1, tb[i] = tb[i - 1];
    else
      ta[i] = 0, tb[i] = tb[i - 1] + 1;
  }
  int i = -1;
  scanf("%d", &q);
  while (q--) {
    i++;
    int x, y, X, Y;
    scanf("%d%d%d%d", &x, &y, &X, &Y);
    int s_trA = min(y - x + 1, sa[y]), t_trA = min(Y - X + 1, ta[Y]);
    int s_b = sb[y] - sb[x - 1], t_b = tb[Y] - tb[X - 1];
    if (s_b == t_b) {
      if (s_trA >= t_trA && (s_trA - t_trA) % 3 == 0)
        ara[i] = '1';
      else
        ara[i] = '0';
    } else if (s_b > 0 && t_b > 0) {
      if (s_b <= t_b && (t_b - s_b) % 2 == 0 && s_trA >= t_trA)
        ara[i] = '1';
      else
        ara[i] = '0';
    } else if (t_b > 0) {
      if (t_b % 2 == 0 && t_trA < s_trA)
        ara[i] = '1';
      else
        ara[i] = '0';
    } else if (s_b > 0) {
      ara[i] = '0';
    } else {
      if (s_trA >= t_trA && (s_trA - t_trA) % 3 == 0)
        ara[i] = '1';
      else
        ara[i] = '0';
    }
  }
  ara[i + 1] = 0;
  puts(ara);
  return 0;
}
