#include<iostream>
#include<cstdio> 
char s[100005],t[100005];  
int sp[100005],tp[100005],q,a,b,c,d,i;  
int main(){  
    scanf("%s%s%d",s+1,t+1,&q);  
    for(i=1;s[i];++i)  sp[i]=sp[i-1]+s[i]-'A'+1;  
    for(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;
}
