#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 5;

long long S[maxn], a[maxn];

int sum[maxn<<2];
int up[maxn<<2];

void push_up(int i)
{
    sum[i]=sum[i<<1]+sum[i<<1|1];
}

void push_down(int i,int l,int r)
{
    if(up[i]!=-1)
    {
        int mid=(l+r)>>1;
        sum[i<<1]=up[i]*(mid-l+1);
        sum[i<<1|1]=up[i]*(r-mid);
        up[i<<1]=up[i];
        up[i<<1|1]=up[i];
        up[i]=-1;
    }
}

void build(int i,int l,int r)
{
    up[i]=-1;
    if(l==r)
    {
        sum[i]=1;
        return ;
    }
    int mid=(l+r)>>1;
    build(i<<1,l,mid);
    build(i<<1|1,mid+1,r);
    push_up(i);
}

void update(int i,int l,int r,int x,int y,int val)
{
    if(x<=l&&r<=y)
    {
        sum[i]=val*(r-l+1);
        up[i]=val;
        return ;
    }
    push_down(i,l,r);
    int mid=(l+r)>>1;
    if(x<=mid)
        update(i<<1,l,mid,x,y,val);
    if(y>mid)
        update(i<<1|1,mid+1,r,x,y,val);
    push_up(i);
}

int query(int i,int l,int r,int x,int y)
{
    if(x<=l&&r<=y)
        return sum[i];
    push_down(i,l,r);
    int mid=(l+r)>>1;
    int sum=0;
    if(x<=mid)
        sum+=query(i<<1,l,mid,x,y);
    if(y>mid)
        sum+=query(i<<1|1,mid+1,r,x,y);
    return sum;
}

/*
void read_and_parse(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	root=build(1,n);
}

void solve(){
	while(m--){
		int opt,val,l,r;
		scanf("%d",&opt);
		if(opt==1){
			scanf("%d%d%d",&l,&r,&val);
			modify(root,1,n,l,r,val);
		}else{
			scanf("%d%d",&l,&r);
			printf("%lld\n",query(root,1,n,l,r));
		}
	}
}*/

pair<int, int> que[maxn];

int main()
{
    int T;
    scanf("%d", &T);
    while(T--)
    {
        int n, q;
        scanf("%d%d", &n, &q);
        build(1, 0, n - 1);

        for(int i = 1; i <= n; i++)
            scanf("%1d", &S[i]);
        for(int i = 1; i <= n; i++)
            scanf("%1d", &a[i]);


        for(int i = 1; i <= n; i++)
            update(1, 0, n - 1, i - 1, i - 1, a[i]);

        bool p = 1;

        for(int i = 1; i <= q; i++)
            scanf("%d%d", &que[i].first, &que[i].second);

        for(int i = q; i >= 1; i--)
        {
            int l = que[i].first - 1, r = que[i].second - 1;

            int cnt = query(1, 0, n - 1, l, r);
            int all = r - l + 1;

            if(cnt * 2 == all) p = 0;
            else if(cnt * 2 < all) update(1, 0, n - 1, l, r, 0);
            else update(1, 0, n - 1, l, r, 1);

        }

        if(p)
        {
            for(int i = 0; i < n; i++)
                if(S[i + 1] != query(1, 0, n - 1, i, i))
                {
                    p = 0;
                    break;
                }
        }


        if(p) puts("YES");
        else puts("NO");

    }
	return 0;
}
