#include <iostream>
#include <vector>
#include <string>
using namespace std;

string st[2];
vector<int> va[2];

void calcu(int idx) {
	for (int p = 0; p < (int)st[idx].length(); ++p) {
		int add = (st[idx][p] == 'A') ? 1 : 2;
		va[idx][p + 1] = va[idx][p] + add;
	}
}

int main(void) {
	int q, a, b, c, d;

	for (int i = 0; i < 2; ++i) {
		cin >> st[i];
		va[i].resize((int)st[i].length() + 1, 0);
		calcu(i);
	}
	cin >> q;
	for (int i = 0; i < q; ++i) {
		cin >> a >> b >> c >> d;
		int sa = va[0][b] - va[0][a - 1];
		int ta = va[1][d] - va[1][c - 1];
		if (sa % 3 == ta % 3)
			cout << "YES\n";
		else
			cout << "NO\n";
	}

	return 0;
}
