#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
int a,b,c,d,q;
ll li[100010],lo[100010];
string s,w;

int main(){
	cin >> s >> w >> q;
	REP(i,0,s.size()){
		if(s[i]=='A') li[i+1]=(li[i]+1);
		if(s[i]=='B') li[i+1]=(li[i]+2);
	}
	REP(i,0,w.size()){
		if(w[i]=='A') lo[i+1]=(lo[i]+1);
		if(w[i]=='B') lo[i+1]=(lo[i]+2);
	}
	
	REP(i,0,q){
		cin >> a >> b >> c >> d;
		cout << ((li[b]-li[a-1])%3==(lo[d]-lo[c-1])%3?"YES":"NO") << endl;
	}
	
	return 0;
}
