#include <bits/stdc++.h>
using namespace std;

int s[100010], t[100010], n, l, r, L, R;
string S, T;

int main() {
    iostream::sync_with_stdio(0); cin.tie(0);
    cin >> S >> T >> n;
    for(int i = 1; i <= S.length(); i++) s[i] = (s[i-1] + (S[i-1] - 'A' + 1)) % 3;
    for(int i = 1; i <= T.length(); i++) t[i] = (t[i-1] + (T[i-1] - 'A' + 1)) % 3;
    while(n--) {
        cin >> l >> r >> L >> R;
        if((s[r] - s[l-1] - t[R] + t[L-1]) % 3 == 0) cout << "YES\n";
        else cout << "NO\n";
    }
}