#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S, T; cin >> S >> T;
    vector<int> A(S.size()+1), B(T.size()+1);
    for (int i = 0; i < S.size(); i++) {
        A[i+1] = A[i] + (S[i] == 'A' ? 1 : 2);
    }
    for (int i = 0; i < T.size(); i++) {
        B[i+1] = B[i] + (T[i] == 'A' ? 1 : 2);
    }
    int Q; cin >> Q;
    const char *YESNO[] = { "NO", "YES" };
    for (int i = 0; i < Q; i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        cout << YESNO[(A[b+1] - A[a]) % 3 == (B[d+1] - B[c]) % 3] << '\n';
    }
    return 0;
}