#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	string S, T; 
	cin >> S >> T; 
	int A[100010] = {}; 
	int B[100010] = {}; 
	for(int i = 1; i <= S.size(); i++){
		A[i] = A[i-1] + 1 + S.at(i-1) - 'A'; 
	}
  	for(int i = 1; i <= T.size(); i++){
		B[i] = B[i-1] + 1 + T.at(i-1) - 'A';
	}
	int Q; 
	cin >> Q; 
	for(int i = 0; i < Q; i++){
		int a, b, c, d; 
		cin >> a >> b >> c >> d; 
		if((A[b] - A[a-1]) % 3 == (B[d] - B[c-1]) % 3){
			cout << "YES" << endl; 
		}
		else{
			cout << "NO" << endl; 
		}
	}
}