#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf64 = 1e18;
struct info {
  vector<int> x, a;
  vector<int> p;
  void print() {
    cout << "p : ";
    for (int t : p) {
      cout << t << " ";
    }
    cout << "\n";
    cout << "x : ";
    for (int t : x) {
      cout << t << " ";
    }
    cout << "\n";
    cout << "a : ";
    for (int t : a) {
      cout << t << " ";
    }
    cout << "\n";
  }
};
info get(string s) {
  info res;
  res.x.resize(s.size());
  res.a.resize(s.size());
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] != 'A') {
      res.p.push_back(i);
    }
    if (i > 0) {
      res.x[i] = res.x[i - 1];
      res.a[i] = res.a[i - 1];
    } else {
      res.x[i] = res.a[i] = 0;
    }
    if (s[i] == 'A') {
      res.a[i]++;
    } else {
      res.x[i]++;
    }
  }
  return res;
}
pair<int, int> get(const info& t, int l, int r) {
  int x = t.x[r] - (l > 0 ? t.x[l - 1] : 0);
  if (x == 0) {
    return make_pair(0, r - l + 1);
  }
  int j = upper_bound((t.p).begin(), (t.p).end(), r) - t.p.begin() - 1;
  j = t.p[j];
  int a = t.a[r] - t.a[j];
  return make_pair(x, a);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  info is = get(s);
  info it = get(t);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    l1--;
    r1--;
    l2--;
    r2--;
    pair<int, int> p1 = get(is, l1, r1);
    pair<int, int> p2 = get(it, l2, r2);
    if (p1.first > p2.first || (p1.first - p2.first) % 2 ||
        p1.second < p2.second) {
      cout << "0";
    } else {
      int nx = p2.first - p1.first;
      int na = p1.second - p2.second;
      if (nx == 0) {
        if (na == 0) {
          cout << "1";
        } else {
          if (na % 3) {
            cout << "0";
          } else {
            cout << "1";
          }
        }
      } else {
        if (na == 0) {
          if (p1.first == 0) {
            cout << "0";
          } else {
            cout << "1";
          }
        } else {
          cout << "1";
        }
      }
    }
  }
  cout << "\n";
  return 0;
}
