#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-13
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.9lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0)
#define endl '\n'
using namespace std;
int tree[1000004],tree1[1000003];
string s,t;
void build(int node, int start, int end)

{
    if(start == end)tree1[node] = s[start]-'A'+1;
    else
    {
        long mid = (start + end) / 2;
        build(2*node, start, mid);
        build(2*node+1, mid+1, end);
        if(tree1[2*node]==0){tree1[node]=tree1[2*node+1];return ;}
        if(tree1[2*node+1]==0){tree1[node]=tree1[2*node];return ;}
        if(tree1[2*node]==tree1[2*node+1])
        {
            if(tree1[2*node]==1)tree1[node]=2;
            else tree1[node]=1;
            return ;
        }
        tree1[node]=0;

    }
}
int  query(long node, long  start, long  end, long  l, long r){
if(r < start || end < l)return 0;
     if(l <= start and end <= r)
    {return tree1[node];}

    int mid = (start + end) / 2;
    if(r<=mid)return query(2*node, start, mid, l, r);
    if(l>=mid+1)return query(2*node+1, mid+1, end, l, r);
   int p1 = query(2*node, start, mid, l, r);
    int p2 = query(2*node+1, mid+1, end, l, r);
    if(p1==0)return p2;
    if(p2==0)return p1;
    if(p1==p2)
    {
        if(p1==1)return 2;
        else return 1;
    }
    return 0;

}

void build1(int node, int start, int end)

{
    if(start == end)tree[node] = t[start]-'A'+1;
    else
    {
        long mid = (start + end) / 2;
        build1(2*node, start, mid);
        build1(2*node+1, mid+1, end);
        if(tree[2*node]==0){tree[node]=tree[2*node+1];return ;}
        if(tree[2*node+1]==0){tree[node]=tree[2*node];return ;}
        if(tree[2*node]==tree[2*node+1])
        {
            if(tree[2*node]==1)tree[node]=2;
            else tree[node]=1;
            return ;
        }
        tree[node]=0;

    }
}
int  query1(long node, long  start, long  end, long  l, long r){
if(r < start || end < l)return 0;
     if(l <= start and end <= r)
    {return tree[node];}

    int mid = (start + end) / 2;
    if(r<=mid)return query1(2*node, start, mid, l, r);
    if(l>=mid+1)return query1(2*node+1, mid+1, end, l, r);
   int p1 = query1(2*node, start, mid, l, r);
    int p2 = query1(2*node+1, mid+1, end, l, r);
    if(p1==0)return p2;
    if(p2==0)return p1;
    if(p1==p2)
    {
        if(p1==1)return 2;
        else return 1;
    }
    return 0;

}
int main()
{

    cin>>s>>t;
    int q;
    cin>>q;
    int n=s.size();int m=t.size();
    build(1,0,n-1);
    build1(1,0,m-1);
    for(int i=1;i<=q;i++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int x=query(1,0,n-1,a-1,b-1);
        int y=query1(1,0,m-1,c-1,d-1);
    //    cout<<x<<" "<<y<<endl;
        if(x==y){cout<<"YES"<<endl;}
        else cout<<"NO"<<endl;

    }

}




Measured memory_bytes: 6016