#include "bits/stdc++.h"

#ifdef WINT_MIN
#define __MAI
#endif

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u) { if (u == 0)cout << 0; else { int s = 0, k = 0; for (; 0<u; u >>= 1, k++)s = (s << 1) | (u & 1); for (; 0<k--; s >>= 1)cout << (s & 1); } }template<typename T1, typename T2>
    ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; }

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

namespace {
    std::chrono::system_clock::time_point t;
    void tic() { t = TIME; }
    void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); }
    std::chrono::system_clock::time_point tle = TIME;
#ifdef __MAI
    void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); }
#else
#define safe_tle(k) ;
#endif
}

#ifndef __MAI 
namespace {
    class MaiScanner {
    public:
        template<typename T>
        void input_integer(T& var) {
            var = 0;
            T sign = 1;
            int cc = getchar_unlocked();
            for (; cc<'0' || '9'<cc; cc = getchar_unlocked())
                if (cc == '-') sign = -1;
            for (; '0' <= cc&&cc <= '9'; cc = getchar_unlocked())
                var = (var << 3) + (var << 1) + cc - '0';
            var = var*sign;
        }
        void ign() { getchar_unlocked(); }
        MaiScanner& operator>>(int& var) {
            input_integer<int>(var);
            return *this;
        }
        MaiScanner& operator>>(long long& var) {
            input_integer<long long>(var);
            return *this;
        }
    };
}
MaiScanner scanner;
#else
#define scanner cin
#endif

template<typename T, T idt = 0x7FFFFFFF, typename Compare = std::less<T>>
class segtree {
    size_t size;
    vector<T> data;
    Compare cp;

    const T& selector(const T& x, const T& y) const {
        return cp(x, y) ? x : y;
    }
public:

    segtree(size_t n) {
        size = 1;
        while (size<n) size <<= 1;
        data.resize(size * 2);
    }

    void fill(const T& e) {
        std::fill(data.begin(), data.end(), e);
    }

    const T& operator[](size_t index) const {
        return data[size - 1 + index];
    }

    void update(size_t index, const T& e) {
        index += size - 1;
        data[index] = e;
        while (0 < index) {
            index = (index - 1) / 2; // 親へ移動
            data[index] = selector(data[index * 2 + 1], data[index * 2 + 2]); // iの子を参照して、d[i]を更新する
        }
    }

    T query(size_t begin, size_t end, size_t ptr = 0, size_t rangebegin = 0, size_t rangeend = 0) const {
        if (rangeend <= rangebegin) { rangeend = size; }

        if (rangeend <= begin || end <= rangebegin) return idt;
        if (begin <= rangebegin && rangeend <= end) return data[ptr];

        size_t rangemid = (rangebegin + rangeend) / 2;
        return selector(query(begin, end, ptr * 2 + 1, rangebegin, rangemid), query(begin, end, ptr * 2 + 2, rangemid, rangeend));
    }

};



int n, m, nquery;

string ss;
string tt;

int imos_s_a[100010];
int imos_s_b[100010];
int imos_t_a[100010];
int imos_t_b[100010];

int table[3][3] = { {0,2,1},{1,0,2},{2,1,0} };


int main() {
    ll i, j, k;
    int a, b, c, d;

    cin >> ss >> tt;

    for (i = 0; i < ss.size(); ++i) {
        imos_s_a[i + 1] = imos_s_a[i] + (ss[i] == 'A');
        imos_s_b[i + 1] = imos_s_b[i] + (ss[i] == 'B');
    }
    for (i = 0; i < tt.size(); ++i) {
        imos_t_a[i + 1] = imos_t_a[i] + (tt[i] == 'A');
        imos_t_b[i + 1] = imos_t_b[i] + (tt[i] == 'B');
    }

    int na, nb, ma, mb;
    int s, t;

    cin >> nquery;
    for (i = 0; i < nquery; ++i) {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        na = imos_s_a[b] - imos_s_a[a - 1];
        nb = imos_s_b[b] - imos_s_b[a - 1];
        ma = imos_t_a[d] - imos_t_a[c - 1];
        mb = imos_t_b[d] - imos_t_b[c - 1];
        s = table[na % 3][nb % 3];
        t = table[ma % 3][mb % 3];
        if (s == t) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }


    return 0;
}

Measured memory_bytes: 2432