import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

class X{
	
	}

void main(){
	// A=1、B=2として、区間の合計を3で割った余りが一致すればYES。一致しなければNO
	
	// xs[i]はSの先頭i文字を3で割った余りを保持する
	// ys[i]はTの先頭i文字を3で割った余りを保持する
	
	// 求めるものは (xs[b] - xs[a - 1]) == (ys[d] - ys[c - 1])
	
	string s = readln.chomp;
	string t = readln.chomp;
	
	int[] xs = [0];
	int x = 0;
	foreach(c; s){
		if(c == 'A') x += 1; else x += 2;
		xs ~= x;
		}
	
	debug xs.writeln;
	
	int[] ys = [0];
	int y = 0;
	foreach(c; t){
		if(c == 'A') y += 1; else y += 2;
		ys ~= y;
		}
	
	debug ys.writeln;
	
	int q = read.to!int;
	for(int i = 0; i < q; i ++){
		int a = read.to!int;
		int b = read.to!int;
		int c = read.to!int;
		int d = read.to!int;
		
		string ans;
		if((xs[b] - xs[a - 1]) % 3 == (ys[d] - ys[c - 1]) % 3) ans = "YES";
		else ans = "NO";
		
		ans.writeln;
		}
	
	}