#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 200006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/
int cnt[2][maxn][2];

int main()
{
   string s,t;
   cin >> s >> t;
   for(int i=0;i<s.length();i++)
   {
     if(s[i]=='A')
      cnt[0][i][0]++;
     else
      cnt[0][i][1]++;
     if(i>0)
      cnt[0][i][0]+=cnt[0][i-1][0];
     if(i>0)
      cnt[0][i][1]+=cnt[0][i-1][1];
   }

   for(int i=0;i<t.length();i++)
   {
     if(t[i]=='A')
      cnt[1][i][0]++;
     else
      cnt[1][i][1]++;
    if(i>0)
      cnt[1][i][0]+=cnt[1][i-1][0];
    if(i>0)
      cnt[1][i][1]+=cnt[1][i-1][1];
   }

   int q;
   cin >> q;
   while(q--)
   {
    int a,b,c,d;
     cin >> a >> b >> c >> d;
     a--;b--;c--;d--;
    
     int cnta1=cnt[0][b][0]-cnt[0][a-1][0];
     int cntb1=cnt[0][b][1]-cnt[0][a-1][1];
     int cnta2=cnt[1][d][0]-cnt[1][c-1][0];
     int cntb2=cnt[1][d][1]-cnt[1][c-1][1];
     int diff1=cnta1-cntb1;
     int diff2=cnta2-cntb2;
     //trace2(diff1,diff2);
     if((diff1*diff2)>0)
     {
       int rem1=(abs(diff1)%3);
       int rem2=(abs(diff2)%3);
       if(rem1==rem2)
       {
         cout << "YES"<<"\n";
       }
       else
       {
         cout << "NO"<<"\n";
       }
     }
     else
     {
       int rem1=(abs(diff1)%3);
       int rem2=(abs(diff2)%3);
       rem1=3-rem1;
       rem1%=3;
       if(rem1==rem2)
       {
         cout << "YES"<<"\n";
       }
       else
       {
         cout << "NO"<<"\n";
       }

     }
   }
}

Measured memory_bytes: 2432