#include<cstdio>
#include<cstring>
#define MN 100005
int cnt1[MN],cnt2[MN]; 
char s1[MN],s2[MN];int q;
inline void pre(){
	memset(cnt1,0,sizeof(0));memset(cnt2,0,sizeof(0));
	for(int i=1;s1[i];i++) cnt1[i]=cnt1[i-1]+s1[i]-'A'+1;
	for(int i=1;s2[i];i++) cnt2[i]=cnt2[i-1]+s2[i]-'A'+1;
}
int main(){
	scanf("%s%s%d",s1+1,s2+1,&q);pre();
	for(int w=1;w<=q;w++){
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		if((cnt1[b]-cnt1[a-1])%3==(cnt2[d]-cnt2[c-1])%3) printf("YES\n");
		else printf("NO\n");
	}
} 