#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infi INT_MAX
#define rinfi INT_MIN
#define inf LLONG_MAX
#define rinf LLONG_MIN
#define ff first
#define ss second
#ifndef ONLINE_JUDGE
#define line cout<<"here - "<<__LINE__<<"\n";
#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
#define db(a,b) cout<<#a<<" --> "<<(a)<<"\n";cin>>b;
#else
#define line
#define dbg(a)
#define db(a,b)
#endif
char _;
using namespace std;
const int mx=1e6+10;
int dp[mx][5];
main()
{
    fast
    int tc=1;
    while(tc--)
    {
        int a, b;
        cin>>a>>b;
        string s, t;
        cin>>s>>t;
        
        int ma = 0;
        for(int i = 0; i < a; i++) if(s[i]=='0') ma++;
        for(int i = 0; i < a; i++) if(t[i]=='0') ma++;
        
        if(s[0]=='0' && t[0]=='0') dp[0][2]=1;
        for(int i = 1; i < a; i++)
        {
            for(int j = 0; j < 3; j++) dp[i][j] = dp[i-1][j];
            
            if(s[i]=='0' &&  s[i-1]=='0')
            {
                dp[i][0] = max(dp[i][0], 1 + dp[i-1][1]);
                if(i-2 >= 0) dp[i][0] = max(dp[i][0], 1 + dp[i-2][2]);
            }
            if(t[i]=='0' &&  t[i-1]=='0')
            {
                dp[i][1] = max(dp[i][1], 1 + dp[i-1][0]);
                if(i-2 >= 0) dp[i][1] = max(dp[i][1], 1 + dp[i-2][2]);
            }
            if(s[i]=='0' && t[i]=='0') dp[i][2] = max({dp[i-1][0], dp[i-1][1], dp[i-1][2]}) + 1;
        }
        
        int ans = 0;
        for(int j = 0; j < 3; j++) ans=max(ans,dp[a-1][j]);
        while(b--)
        {
            int x, y;
            cin>>x>>y;
            int ok = 1;
            if(((x*2)+y) > ma || x > ans) ok=0;
            if(ok) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }
}