#include<bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define float long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define uid uniform_int_distribution<int>
#define forx(x) for(int i=0;i<n;i++){ cout<<x[i]<<" "; } cout<<endl;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7;//998244353;
const int64_t INF = 1e18;

const int MAXN = 2e5 +7;
int n,q;
vector<int> tree,lazy;

void prop(int root,int L,int R){
    int mid=(L+R)>>1;
    lazy[root*2]=lazy[root];   tree[root*2]=(mid-L+1)*lazy[root];
    lazy[root*2+1]=lazy[root]; tree[root*2+1]=(R-mid)*lazy[root];
    lazy[root]=0;
}

void update(int root,int L,int R,int l,int r,int val){
    if(L>r || R<l) return;
    if(l<=L && R<=r){
        lazy[root]=val;
        tree[root]=(R-L+1)*val;
        return;
    }
    if(lazy[root]) prop(root,L,R);
    int mid=(L+R)>>1;
    update(root*2,L,mid,l,r,val);
    update(root*2+1,mid+1,R,l,r,val);
    tree[root]=tree[root*2]+tree[root*2+1];
}

int query(int root,int L,int R,int l,int r){
    if(L>r || R<l) return 0;
    if(l<=L && R<=r) return tree[root];
    if(lazy[root]) prop(root,L,R);
    int mid=(L+R)>>1;
    return query(root*2,L,mid,l,r)+query(root*2+1,mid+1,R,l,r);
}

string solve(){
    cin>>n>>q;
    vector<int> a(n+1),b(n+1);
    for(int i=1;i<=n;i++){
        char x;
        cin>>x;
        a[i]= x=='0'? -1:1;
    }
    for(int i=1;i<=n;i++){
        char x;
        cin>>x;
        b[i]= x=='0'? -1:1;
    }
    tree.resize(4*n,0);
    lazy.resize(4*n,0);
    for(int i=1;i<=n;i++) update(1,1,n,i,i,b[i]);
    vector<pii> Q(q);
    for(int i=0;i<q;i++) cin>>Q[i].fi>>Q[i].se;
    for(int i=q-1;i>=0;i--){
        int l=Q[i].fi,r=Q[i].se;
        int sum=query(1,1,n,l,r);
        if(!sum) return "NO";
        if(sum>0) update(1,1,n,l,r,1);
        else update(1,1,n,l,r,-1);
    }
    for(int i=1;i<=n;i++){
        if(a[i]!=query(1,1,n,i,i)) return "NO";
    }
    return "YES";
}


int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie();
    //If you hack my code , You are gay
    int T;
    cin>>T;
    while(T--){
        cout<<solve()<<"\n";
    }
    return 0;
}

/*
1
2
1
1
2
1
*/