#include<cstdio> 
#include<cstring>

const int N = 1000000;  
char s[N], t[N];  
int sp[N], tp[N], q, a, b, c, d;
int main() {
    scanf("%s%s%d", s + 1, t + 1, &q); 
    for (int i = 1; s[i]; i++) {
        sp[i] = sp[i - 1] + s[i] - 'A' + 1;  
    }
    for (int i = 1; t[i]; i++) {
        tp[i] = tp[i - 1] + t[i] - 'A'  + 1;  
    }
    while(q--) {  
        scanf("%d%d%d%d", &a, &b, &c, &d);  
        if ( (sp[b] - sp[a - 1]) % 3 == (tp[d] - tp[c - 1]) % 3)	{
            printf("YES\n");
		}
        else {
            printf("NO\n"); 
		}
    }  
    return 0;  
}  