"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var s = nextstr(), sl = s.length;
  var t = nextstr(), tl = t.length;
  var a = xArray(0,sl+1);
  var b = xArray(0,tl+1);
  var z = {};
  z["A"] = 1, z["B"] = 2;
  for(var i = 0; i < sl; i++){
    a[i+1] = a[i] + z[s[i]];
  }
  for(var i = 0; i < tl; i++){
    b[i+1] = b[i] + z[t[i]];
  }
  var q = next();
  var ans = xArray("'YES'",q);
  for(var i = 0; i < q; i++){
    var [u,v,w,x] = nexts(4);
    u--, w--;
    var c = (a[v]-a[u]) % 3;
    var d = (b[x]-b[w]) % 3;
    if(c !== d)ans[i] = "NO";
  }
  return ans.join("\n");
}