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


const int maxn = 2e5+5;
typedef long long ll;

char s[maxn],f[maxn];
int t[maxn<<2],lz[maxn<<2];

void pushup(int rt){
	t[rt]=t[rt<<1]+t[rt<<1|1];
}
void pushdown(int rt,int l,int r){
	if(lz[rt]!=-1){
		int mid=l+r>>1;
		t[rt<<1]=lz[rt]*(mid-l+1);
		t[rt<<1|1]=lz[rt]*(r-mid);
		lz[rt<<1]=lz[rt<<1|1]=lz[rt];
		lz[rt]=-1;
	}
}
void build(int rt,int l,int r){
	lz[rt]=-1;
	if(l==r){
		t[rt]=f[l]-'0';
		return;
	}
	int mid=l+r>>1;
	build(rt<<1,l,mid);
	build(rt<<1|1,mid+1,r);
	pushup(rt);
}
void cg(int rt,int l,int r,int ql,int qr,int v){
	if(l>=ql && r<=qr){
		t[rt]=(r-l+1)*v;
		lz[rt]=v; 
		return;
	}
	int mid=l+r>>1;
	pushdown(rt,l,r);
	if(ql<=mid && qr>=l)cg(rt<<1,l,mid,ql,qr,v);
	if(ql<=r && qr>=mid+1)cg(rt<<1|1,mid+1,r,ql,qr,v);
	pushup(rt);
}
int qry(int rt,int l,int r,int ql,int qr){
	if(l>=ql && r<=qr){
		return t[rt];
	} 
	pushdown(rt,l,r);
	int mid=l+r>>1;
	int ans=0;
	if(ql<=mid)ans+=qry(rt<<1,l,mid,ql,qr);
	if(qr>=mid+1)ans+=qry(rt<<1|1,mid+1,r,ql,qr);
	pushup(rt);
	return ans;
}

struct Node{
	int l,r;
}a[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n,q;
		scanf("%d%d%s%s",&n,&q,s+1,f+1);
		build(1,1,n);
		bool failed=false;
		for(int i=1;i<=q;++i){
			scanf("%d%d",&a[i].l,&a[i].r);
		}
		for(int i=q;i>=1;--i){
			int l=a[i].l,r=a[i].r;
			int num=qry(1,1,n,l,r),k=(r-l+2)/2-1;
			if(r-l+1<=2){
				if(num!=r-l+1 && num){
					failed=true;
					break;
				}
			}else if(r-l+1-num<=k)cg(1,1,n,l,r,1);else if(num<=k)cg(1,1,n,l,r,0);else{
				if(num!=r-l+1 && num){
					failed=true;
					break;
				}
			}
		}
		if(failed){
			printf("NO\n");
			continue;
		}
		for(int i=1;i<=n;++i){
			if(qry(1,1,n,i,i)!=s[i]-'0'){
				failed=true;
				break;
			}
		}
		if(failed){
			printf("NO\n");
		}else printf("YES\n");
	}
}/*test:
2
9 10
111101101
110001101
7 7
9 9
5 5
1 4
7 7
3 3
5 5
9 9
9 9
5 5
*/