#include <bits/stdc++.h>

using namespace std;

string a, b;
int A[100050], B[100050];
int main(){
	cin >> a >> b;
	int n=a.length(), m=b.length();
	for(int i = 0; i<n; i++){
		if(a[i] == 'A') A[i+1]=1;
		else A[i+1]=2;
	}
	for(int i = 0; i<m; i++){
		if(b[i] == 'A') B[i+1]=1;
		else B[i+1]=2;
	}
	for(int i = 1; i<=n; i++) A[i]+=A[i-1];
	for(int i = 1; i<=m; i++) B[i]+=B[i-1];
	int q; cin >> q;
	while(q--){
		int c, d, e, f; cin >> c >> d >> e >> f;
		if((A[d]-A[c-1])%3 == (B[f]-B[e-1])%3) cout << "YES\n";
		else cout << "NO\n";
	}
}
