#include <bits/stdc++.h>
using namespace std;
int sCnt[100004], tCnt[100004], q, a, b, c, d;

int main() {
	string s;
	memset(sCnt,0,sizeof(sCnt));
	memset(tCnt,0,sizeof(tCnt));
	cin>>s;
	for(int i = 1 ; i <= s.length();i++){
		if(s[i-1]=='A')	sCnt[i] = sCnt[i-1]+1;
		else	sCnt[i] = sCnt[i-1];
	}
	cin>>s;
	for(int i = 1 ; i <= s.length();i++){
		if(s[i-1]=='A')	tCnt[i] = tCnt[i-1]+1;
		else	tCnt[i] = tCnt[i-1];
	}
	cin>>q;
	while(q--){
		cin>>a>>b>>c>>d;
		int x = sCnt[b]-sCnt[a-1], y = tCnt[d]-tCnt[c-1];
		x = (x+b-a+1)%3, y = (y+d-c+1)%3;
		if(x==y)	cout<<"YES\n";
		else	cout<<"NO\n";
	}
	return 0;
}