#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<ctime>
using namespace std;
namespace onlyzhao
{
    #define ui unsigned int
    #define ll long long
    #define llu unsigned ll
    #define ld long double
    #define pr make_pair
    #define pb push_back
    #define lc (cnt<<1)
    #define rc (cnt<<1|1)
    #define len(x)  (t[(x)].r-t[(x)].l+1)
    #define tmid ((l+r)>>1)
    #define fhead(x) for(int i=head[(x)];i;i=nt[i])
    #define max(x,y) ((x)>(y)?(x):(y))
    #define min(x,y) ((x)>(y)?(y):(x))
    #define one(n) for(int i=1;i<=(n);i++)
    #define rone(n) for(int i=(n);i>=1;i--)
    #define fone(i,x,n) for(int i=(x);i<=(n);i++)
    #define frone(i,n,x) for(int i=(n);i>=(x);i--)
    #define fonek(i,x,n,k) for(int i=(x);i<=(n);i+=(k))
    #define fronek(i,n,x,k) for(int i=(n);i>=(x);i-=(k))
    #define two(n,m) for(int i=1;i<=(n);i++) for(int j=1;j<=(m);j++)
    #define ftwo(i,n,j,m) for(int i=1;i<=(n);i++) for(int j=1;j<=(m);j++)
    #define fvc(vc) for(int i=0;i<vc.size();i++)
    #define frvc(vc) for(int i=vc.size()-1;i>=0;i--)
    #define forvc(i,vc) for(int i=0;i<vc.size();i++)
    #define forrvc(i,vc) for(int i=vc.size()-1;i>=0;i--)
    #define cls(a) memset(a,0,sizeof(a))
    #define cls1(a) memset(a,-1,sizeof(a))
    #define clsmax(a) memset(a,0x3f,sizeof(a))
    #define clsmin(a) memset(a,0x80,sizeof(a))
    #define cln(a,num) memset(a,0,sizeof(a[0])*num)
    #define cln1(a,num) memset(a,-1,sizeof(a[0])*num)
    #define clnmax(a,num) memset(a,0x3f,sizeof(a[0])*num)
    #define clnmin(a,num) memset(a,0x80,sizeof(a[0])*num)
    #define sc(x) scanf("%d",&x)
    #define sc2(x,y) scanf("%d%d",&x,&y)
    #define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
    #define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d);
    #define scl(x) scanf("%lld",&x)
    #define scl2(x,y) scanf("%lld%lld",&x,&y)
    #define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
    #define scf(x) scanf("%lf",&x)
    #define scf2(x,y) scanf("%lf%lf",&x,&y)
    #define scf3(x,y,z) scanf("%lf%lf%lf",&x,&y,&z)
    #define scs(x) scanf("%s",x+1)
    #define scs0(x) scanf("%s",x)
    #define scline(x) scanf("%[^\n]%*c",x+1)
    #define scline0(x) scanf("%[^\n]%*c",x)
    #define pcc(x) putchar(x)
    #define hc pcc('\n')
    #define pc(x) printf("%d\n",x)
    #define pc2(x,y) printf("%d %d\n",x,y)
    #define pc3(x,y,z) printf("%d %d %d\n",x,y,z)
    #define pck(x) printf("%d ",x)
    #define pcl(x) printf("%lld\n",x)
    #define pcl2(x,y) printf("%lld %lld\n",x,y)
    #define pcl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
    #define pclk(x) printf("%lld ",x)
    #define pcf2(x) printf("%.2f\n",x)
    #define pcf6(x) printf("%.6f\n",x)
    #define pcf8(x) printf("%.8f\n",x)
    #define pcs(x) printf("%s\n",x+1)
    #define pcs0(x) printf("%s\n",x)
    #define pcline(x) printf("%d**********\n",x)
    #define casett int tt;sc(tt);int pp=0;while(tt--)
    #define INT 32
    #define LONG 64
    #define intMax (0x7fffffff)
    #define longMax (0x7fffffffffffffff)
    char buffer[100001],*S,*T;
    inline char Get_Char(void)
    {
        if (S==T)
        {
            T=(S=buffer)+fread(buffer,1,100001,stdin);
            if (S==T) return EOF;
        }
        return *S++;
    }
    inline int read(void)
    {
        char c;int re=0;
        for(c=Get_Char();c<'0'||c>'9';c=Get_Char());
        while(c>='0'&&c<='9') re=re*10+(c-'0'),c=Get_Char();
        return re;
    }

    /**************
    mt19937 randseed;
    uniform_int_distribution<int>ran;
    inline void initRand(void)
    {
        randseed=mt19937(time(0));
        ran=uniform_int_distribution<int>(0,intMax);
    }
    inline int getRand(int l,int r)
    {
        return ran(randseed)%(r-l+1)+l;
    }
    inline int getRand(int r)
    {
        return getRand(0,r);
    }
    ********************/
};
using namespace onlyzhao;

const int inf=0x3f3f3f3f;
const ll lnf=0x3f3f3f3f3f3f3f3f;
const double dnf=1e18;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1.0);
const int hp=13331;
const int maxn=200100;
const int maxm=1001000;
const int up=100100;

char s1[maxn],s2[maxn];
int x[maxn],y[maxn];


struct node
{
    int l,r;
    int sum;
    int laz;
}t[maxn<<2];

void pushup(int cnt)
{
    t[cnt].sum=t[lc].sum+t[rc].sum;
}

void pushdown(int cnt)
{
    if(t[cnt].laz!=-1)
    {
        if(t[cnt].laz==0)
        {
            t[lc].sum=t[rc].sum=0;
            t[lc].laz=0;
            t[rc].laz=0;
        }
        else
        {
            t[lc].sum=len(lc),t[rc].sum=len(rc);
            t[lc].laz=1;
            t[rc].laz=1;
        }
        t[cnt].laz=-1;
    }
}

void build(int l,int r,int cnt)
{
    t[cnt].l=l,t[cnt].r=r;
    t[cnt].sum=0;
    t[cnt].laz=-1;
    if(l==r)
    {
        if(s2[l]=='1') t[cnt].sum=1;
        return ;
    }
    build(l,tmid,lc);
    build(tmid+1,r,rc);
    pushup(cnt);
}

int ask(int l,int r,int cnt)
{
    if(l<=t[cnt].l&&t[cnt].r<=r)
        return t[cnt].sum;
    pushdown(cnt);
    int ans=0;
    if(t[lc].r>=l) ans+=ask(l,r,lc);
    if(t[rc].l<=r) ans+=ask(l,r,rc);
    return ans;
}


void change(int l,int r,int cnt,int val)
{
    if(l<=t[cnt].l&&t[cnt].r<=r)
    {
        if(val==0) t[cnt].sum=0,t[cnt].laz=0;
        else t[cnt].sum=len(cnt),t[cnt].laz=1;
        //cout<<"l:   "<<l<<"   "<<r<<"   "<<val<<"   "<<t[cnt].sum<<endl;
        return ;
    }
    pushdown(cnt);
    if(t[lc].r>=l) change(l,r,lc,val);
    if(t[rc].l<=r) change(l,r,rc,val);
    pushup(cnt);

}

bool dfs(int cnt)
{
    if(t[cnt].l==t[cnt].r)
    {
        //cout<<"l:   "<<t[cnt].l<<"   "<<t[cnt].sum<<endl;
        if(t[cnt].sum==0) return s1[t[cnt].l]=='0';
        else return s1[t[cnt].l]=='1';
    }
    pushdown(cnt);
    if(dfs(lc)==true)
        return dfs(rc);
    else return false;
}

bool check(void)
{
    return dfs(1);
}

int main(void)
{
    casett
    {
        int n,q;
        sc2(n,q);
        scs(s1),scs(s2);
        one(q) sc2(x[i],y[i]);
        build(1,n,1);
        bool flag=true;
        for(int i=q;i>=1;i--)
        {
            int le=(y[i]-x[i]+1)/2;
            int sum=ask(x[i],y[i],1);
            //cout<<"sum:   "<<sum<<endl;
            if(sum*2==y[i]-x[i]+1)
            {
                flag=false;
                break;
            }
            if(sum>le) change(x[i],y[i],1,1);
            else change(x[i],y[i],1,0);
            //cout<<"     ******************"<<endl;
        }
        if(flag&&check()) printf("YES\n");
        else printf("NO\n");

    }

}

### Prompt

Develop a solution in CPP to the problem described below:

Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks better.

It is known that Nanako loves consistency so much. On the i-th day, Nanako will inspect a segment of string s from position l_i to position r_i inclusive. If the segment contains both characters '0' and '1', Nanako becomes unhappy and throws away the string.

After this inspection, at the i-th night, Nezzar can secretly change strictly less than half of the characters in the segment from l_i to r_i inclusive, otherwise the change will be too obvious.

Now Nezzar wonders, if it is possible to avoid Nanako being unhappy and at the same time have the string become equal to the string f at the end of these q days and nights.

Input

The first line contains a single integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases.

The first line of each test case contains two integers n,q (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ q ≤ 2 ⋅ 10^5).

The second line of each test case contains a binary string s of length n.

The third line of each test case contains a binary string f of length n.

Then q lines follow, i-th of them contains two integers l_i,r_i (1 ≤ l_i ≤ r_i ≤ n) — bounds of the segment, that Nanako will inspect on the i-th day.

It is guaranteed that the sum of n for all test cases doesn't exceed 2 ⋅ 10^5, and the sum of q for all test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print "YES" on the single line if it is possible to avoid Nanako being unhappy and have the string f at the end of q days and nights. Otherwise, print "NO".

You can print each letter in any case (upper or lower).

Example

Input


4
5 2
00000
00111
1 5
1 3
2 1
00
01
1 2
10 6
1111111111
0110001110
1 10
5 9
7 10
1 7
3 5
6 10
5 2
10000
11000
2 5
1 3


Output


YES
NO
YES
NO

Note

In the first test case, \underline{00000} → \underline{000}11 → 00111 is one of the possible sequences of string changes.

In the second test case, it can be shown that it is impossible to have the string f at the end.

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<ctime>
using namespace std;
namespace onlyzhao
{
    #define ui unsigned int
    #define ll long long
    #define llu unsigned ll
    #define ld long double
    #define pr make_pair
    #define pb push_back
    #define lc (cnt<<1)
    #define rc (cnt<<1|1)
    #define len(x)  (t[(x)].r-t[(x)].l+1)
    #define tmid ((l+r)>>1)
    #define fhead(x) for(int i=head[(x)];i;i=nt[i])
    #define max(x,y) ((x)>(y)?(x):(y))
    #define min(x,y) ((x)>(y)?(y):(x))
    #define one(n) for(int i=1;i<=(n);i++)
    #define rone(n) for(int i=(n);i>=1;i--)
    #define fone(i,x,n) for(int i=(x);i<=(n);i++)
    #define frone(i,n,x) for(int i=(n);i>=(x);i--)
    #define fonek(i,x,n,k) for(int i=(x);i<=(n);i+=(k))
    #define fronek(i,n,x,k) for(int i=(n);i>=(x);i-=(k))
    #define two(n,m) for(int i=1;i<=(n);i++) for(int j=1;j<=(m);j++)
    #define ftwo(i,n,j,m) for(int i=1;i<=(n);i++) for(int j=1;j<=(m);j++)
    #define fvc(vc) for(int i=0;i<vc.size();i++)
    #define frvc(vc) for(int i=vc.size()-1;i>=0;i--)
    #define forvc(i,vc) for(int i=0;i<vc.size();i++)
    #define forrvc(i,vc) for(int i=vc.size()-1;i>=0;i--)
    #define cls(a) memset(a,0,sizeof(a))
    #define cls1(a) memset(a,-1,sizeof(a))
    #define clsmax(a) memset(a,0x3f,sizeof(a))
    #define clsmin(a) memset(a,0x80,sizeof(a))
    #define cln(a,num) memset(a,0,sizeof(a[0])*num)
    #define cln1(a,num) memset(a,-1,sizeof(a[0])*num)
    #define clnmax(a,num) memset(a,0x3f,sizeof(a[0])*num)
    #define clnmin(a,num) memset(a,0x80,sizeof(a[0])*num)
    #define sc(x) scanf("%d",&x)
    #define sc2(x,y) scanf("%d%d",&x,&y)
    #define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
    #define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d);
    #define scl(x) scanf("%lld",&x)
    #define scl2(x,y) scanf("%lld%lld",&x,&y)
    #define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
    #define scf(x) scanf("%lf",&x)
    #define scf2(x,y) scanf("%lf%lf",&x,&y)
    #define scf3(x,y,z) scanf("%lf%lf%lf",&x,&y,&z)
    #define scs(x) scanf("%s",x+1)
    #define scs0(x) scanf("%s",x)
    #define scline(x) scanf("%[^\n]%*c",x+1)
    #define scline0(x) scanf("%[^\n]%*c",x)
    #define pcc(x) putchar(x)
    #define hc pcc('\n')
    #define pc(x) printf("%d\n",x)
    #define pc2(x,y) printf("%d %d\n",x,y)
    #define pc3(x,y,z) printf("%d %d %d\n",x,y,z)
    #define pck(x) printf("%d ",x)
    #define pcl(x) printf("%lld\n",x)
    #define pcl2(x,y) printf("%lld %lld\n",x,y)
    #define pcl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
    #define pclk(x) printf("%lld ",x)
    #define pcf2(x) printf("%.2f\n",x)
    #define pcf6(x) printf("%.6f\n",x)
    #define pcf8(x) printf("%.8f\n",x)
    #define pcs(x) printf("%s\n",x+1)
    #define pcs0(x) printf("%s\n",x)
    #define pcline(x) printf("%d**********\n",x)
    #define casett int tt;sc(tt);int pp=0;while(tt--)
    #define INT 32
    #define LONG 64
    #define intMax (0x7fffffff)
    #define longMax (0x7fffffffffffffff)
    char buffer[100001],*S,*T;
    inline char Get_Char(void)
    {
        if (S==T)
        {
            T=(S=buffer)+fread(buffer,1,100001,stdin);
            if (S==T) return EOF;
        }
        return *S++;
    }
    inline int read(void)
    {
        char c;int re=0;
        for(c=Get_Char();c<'0'||c>'9';c=Get_Char());
        while(c>='0'&&c<='9') re=re*10+(c-'0'),c=Get_Char();
        return re;
    }

    /**************
    mt19937 randseed;
    uniform_int_distribution<int>ran;
    inline void initRand(void)
    {
        randseed=mt19937(time(0));
        ran=uniform_int_distribution<int>(0,intMax);
    }
    inline int getRand(int l,int r)
    {
        return ran(randseed)%(r-l+1)+l;
    }
    inline int getRand(int r)
    {
        return getRand(0,r);
    }
    ********************/
};
using namespace onlyzhao;

const int inf=0x3f3f3f3f;
const ll lnf=0x3f3f3f3f3f3f3f3f;
const double dnf=1e18;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1.0);
const int hp=13331;
const int maxn=200100;
const int maxm=1001000;
const int up=100100;

char s1[maxn],s2[maxn];
int x[maxn],y[maxn];


struct node
{
    int l,r;
    int sum;
    int laz;
}t[maxn<<2];

void pushup(int cnt)
{
    t[cnt].sum=t[lc].sum+t[rc].sum;
}

void pushdown(int cnt)
{
    if(t[cnt].laz!=-1)
    {
        if(t[cnt].laz==0)
        {
            t[lc].sum=t[rc].sum=0;
            t[lc].laz=0;
            t[rc].laz=0;
        }
        else
        {
            t[lc].sum=len(lc),t[rc].sum=len(rc);
            t[lc].laz=1;
            t[rc].laz=1;
        }
        t[cnt].laz=-1;
    }
}

void build(int l,int r,int cnt)
{
    t[cnt].l=l,t[cnt].r=r;
    t[cnt].sum=0;
    t[cnt].laz=-1;
    if(l==r)
    {
        if(s2[l]=='1') t[cnt].sum=1;
        return ;
    }
    build(l,tmid,lc);
    build(tmid+1,r,rc);
    pushup(cnt);
}

int ask(int l,int r,int cnt)
{
    if(l<=t[cnt].l&&t[cnt].r<=r)
        return t[cnt].sum;
    pushdown(cnt);
    int ans=0;
    if(t[lc].r>=l) ans+=ask(l,r,lc);
    if(t[rc].l<=r) ans+=ask(l,r,rc);
    return ans;
}


void change(int l,int r,int cnt,int val)
{
    if(l<=t[cnt].l&&t[cnt].r<=r)
    {
        if(val==0) t[cnt].sum=0,t[cnt].laz=0;
        else t[cnt].sum=len(cnt),t[cnt].laz=1;
        //cout<<"l:   "<<l<<"   "<<r<<"   "<<val<<"   "<<t[cnt].sum<<endl;
        return ;
    }
    pushdown(cnt);
    if(t[lc].r>=l) change(l,r,lc,val);
    if(t[rc].l<=r) change(l,r,rc,val);
    pushup(cnt);

}

bool dfs(int cnt)
{
    if(t[cnt].l==t[cnt].r)
    {
        //cout<<"l:   "<<t[cnt].l<<"   "<<t[cnt].sum<<endl;
        if(t[cnt].sum==0) return s1[t[cnt].l]=='0';
        else return s1[t[cnt].l]=='1';
    }
    pushdown(cnt);
    if(dfs(lc)==true)
        return dfs(rc);
    else return false;
}

bool check(void)
{
    return dfs(1);
}

int main(void)
{
    casett
    {
        int n,q;
        sc2(n,q);
        scs(s1),scs(s2);
        one(q) sc2(x[i],y[i]);
        build(1,n,1);
        bool flag=true;
        for(int i=q;i>=1;i--)
        {
            int le=(y[i]-x[i]+1)/2;
            int sum=ask(x[i],y[i],1);
            //cout<<"sum:   "<<sum<<endl;
            if(sum*2==y[i]-x[i]+1)
            {
                flag=false;
                break;
            }
            if(sum>le) change(x[i],y[i],1,1);
            else change(x[i],y[i],1,0);
            //cout<<"     ******************"<<endl;
        }
        if(flag&&check()) printf("YES\n");
        else printf("NO\n");

    }

}

```