#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  string s,t;
  cin>>s>>t;
  int n;
  cin>>n;
  vector<int> rs(s.size()+1,0);
  for(int i=0;i<s.size();i++){
    if(s[i]=='A')rs[i+1]=rs[i]+1;
    else rs[i+1]=rs[i]+2;
  }
  vector<int> rt(t.size()+1,0);
  for(int i=0;i<t.size();i++){
    if(t[i]=='A')rt[i+1]=rt[i]+1;
    else rt[i+1]=rt[i]+2;
  }

  for(int i=0;i<n;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    c--;
    int sp=rs[b]-rs[a];
    int tp=rt[d]-rt[c];
    if(sp%3==tp%3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}
