#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long INFLL = 1e18 + 1;
const int MAX = 200001;
const long long MOD = 1000000007;
const int SZ = 300100;
const double PI = 3.14159265358979323846264338327;
long long inq(long long k, long long q, long long mod) {
  if (q == 0) return 1;
  long long l = inq(k, q / 2, mod);
  if (q % 2 == 0)
    return l * l % mod;
  else
    return l * l % mod * k % mod;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long cubr(long long a) {
  long long l = -1, r = 1e6 + 2;
  while (l < r - 1) {
    long long mid = (l + r) / 2;
    if (mid * mid * mid > a)
      r = mid;
    else
      l = mid;
  }
  return l;
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) { return -1 * max(-a, -b); }
long long possible(long long q) {
  if (q == INF) return -1;
  return q;
}
bool correct(int x, int xx) {
  if (x < 0) return 0;
  if (x >= xx) return 0;
  return 1;
}
long long dsumm(long long x, long long k) {
  long long y = 1;
  long long z = 0;
  for (int i = 0; y < 1e18; i++) {
    z += x / y % k;
    y *= k;
  }
  return z;
}
long long dcount(long long x) {
  long long y = 1;
  long long z = 0;
  int c[100];
  for (int i = 0; i < 10; i++) c[i] = 0;
  for (int i = 0; x > 0; i++) {
    if (c[x / y % 10] == 0) z++;
    c[x / y % 10] = 1;
    x /= 10;
  }
  return z;
}
long long lg10(long long x) {
  if (10000 <= x && x < 100000) return 5;
  if (x == 0) return 0;
  return lg10(x / 10) + 1;
}
long long g(long long x, long long mod) {
  if (x == 0) return 0;
  return x / mod + g(x / mod, mod);
}
bool is_digit(char c) { return ('0' <= c && c <= '9'); }
string s;
string t;
long long prefAS[500000];
long long prefAT[500000];
long long suffA1[500000];
long long suffA2[500000];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  cin >> t;
  for (long long(i) = 0; (i) != (s.size()); i++) {
    if (s[i] == 'C') s[i] = 'B';
    if (i > 0) prefAS[i] = prefAS[i - 1];
    prefAS[i] += (s[i] == 'A');
  }
  for (long long(i) = 0; (i) != (t.size()); i++) {
    if (t[i] == 'C') t[i] = 'B';
    if (i > 0) prefAT[i] = prefAT[i - 1];
    prefAT[i] += (t[i] == 'A');
  }
  long long aa = 0;
  for (long long(i) = 0; (i) != (s.size()); i++) {
    if (s[i] == 'A')
      aa++;
    else
      aa = 0;
    suffA1[i] = aa;
  }
  aa = 0;
  for (long long(i) = 0; (i) != (t.size()); i++) {
    if (t[i] == 'A')
      aa++;
    else
      aa = 0;
    suffA2[i] = aa;
  }
  long long q;
  cin >> q;
  while (q--) {
    long long l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    l1--;
    r1--;
    l2--;
    r2--;
    long long cntA1 = prefAS[r1] - (l1 > 0 ? prefAS[l1 - 1] : 0);
    long long cntA2 = prefAT[r2] - (l2 > 0 ? prefAT[l2 - 1] : 0);
    long long cntB1 = r1 - l1 + 1 - cntA1;
    long long cntB2 = r2 - l2 + 1 - cntA2;
    long long suffA1q = min(suffA1[r1], r1 - l1 + 1);
    long long suffA2q = min(suffA2[r2], r2 - l2 + 1);
    if (suffA1q % 3 != suffA2q % 3 ||
        (suffA1q == r1 - l1 + 1 && suffA2q != r2 - l2 + 1)) {
      suffA1q--;
      cntB1 += 2;
    }
    if (cntB1 % 2 != cntB2 % 2 || cntB1 > cntB2 || suffA1q < suffA2q) {
      cout << 0;
    } else {
      cout << 1;
    }
  }
}
