#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)

char s1[100001], s2[100001];
int x1[100001], x2[100001];

int main(){
	int q;
	scanf("%s%s%d", s1, s2, &q);
	int n = strlen(s1), m = strlen(s2);
	f(i, 1, n + 1){
		if (s1[i - 1] == 'A')x1[i] = 1; else x1[i] = 2;
		x1[i] += x1[i - 1];
	}
	f(i, 1, m + 1){
		if (s2[i - 1] == 'A')x2[i] = 1; else x2[i] = 2;
		x2[i] += x2[i - 1];
	}
	while (q--){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int z1 = x1[b] - x1[a - 1], z2 = x2[d] - x2[c - 1];
		if (z1 % 3 == z2 % 3)printf("YES\n");
		else printf("NO\n");
	}
}
