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

const int N = 2e5 + 10;
ll sum[N<<2], add[N<<2];

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

void update(int rt, int L, int R, int ql, int qr, int val)
{
    if(ql <= L && R <= qr){
        sum[rt] = 1ll * (R - L + 1) * val;
        add[rt] = val;
        return;
    }
    int M = (L + R) / 2;
    if(add[rt] != -1){
        sum[rt<<1] = (M - L + 1) * add[rt], sum[rt<<1|1] = (R - M) * add[rt];
        add[rt<<1] = add[rt], add[rt<<1|1] = add[rt];
        add[rt] = -1;
    }
    if(ql <= M) update(rt<<1, L, M, ql, qr, val);
    if(M + 1 <= qr) update(rt<<1|1, M + 1, R, ql, qr, val);
    push_up(rt);
}

ll _sum;
void query(int rt, int L, int R, int ql, int qr)
{
    if(ql <= L && R <= qr){
        _sum += sum[rt];
        return;
    }
    int M = (L + R) / 2;
    if(add[rt] != -1){
        sum[rt<<1] = (M - L + 1) * add[rt], sum[rt<<1|1] = (R - M) * add[rt];
        add[rt<<1] = add[rt], add[rt<<1|1] = add[rt];
        add[rt] = -1;
    }
    if(ql <= M) query(rt<<1, L, M, ql, qr);
    if(M + 1 <= qr) query(rt<<1|1, M + 1, R, ql, qr);
}

int n, q, ql[N], qr[N], spre[N];
char s[N], f[N];
int main()
{
    int T;
    scanf("%d", &T);
    while(T--){
        scanf("%d%d", &n, &q);
        for(int i = 1; i <= 4 * n; ++i){
            sum[i] = 0;
            add[i] = -1;
        }
        scanf("%s%s", s + 1, f + 1);

        for(int i = 1; i <= n; ++i){
            update(1, 1, n, i, i, f[i] - '0');
        }

        for(int i = 1; i <= q; ++i){
            scanf("%d%d", &ql[i], &qr[i]);
        }
        bool ok = 1;
        for(int i = q; i >= 1; --i){
            _sum = 0;
            query(1, 1, n, ql[i], qr[i]);
            if((qr[i] - ql[i] + 1) % 2 == 0 && _sum == (qr[i] - ql[i] + 1) / 2){
                ok = 0; break;
            }
            if(_sum <= (qr[i] - ql[i] + 1) / 2) update(1, 1, n, ql[i], qr[i], 0);
            else update(1, 1, n, ql[i], qr[i], 1);
        }
        for(int i = 1; i <= n; ++i){
            spre[i] = spre[i - 1] + (s[i] - '0');
            _sum = 0;
            query(1, 1, n, 1, i);
            ok &= (spre[i] == _sum);
        }
        puts(ok ? "YES" : "NO");
    }
}
### Prompt

Please provide a Cpp coded solution 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<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 2e5 + 10;
ll sum[N<<2], add[N<<2];

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

void update(int rt, int L, int R, int ql, int qr, int val)
{
    if(ql <= L && R <= qr){
        sum[rt] = 1ll * (R - L + 1) * val;
        add[rt] = val;
        return;
    }
    int M = (L + R) / 2;
    if(add[rt] != -1){
        sum[rt<<1] = (M - L + 1) * add[rt], sum[rt<<1|1] = (R - M) * add[rt];
        add[rt<<1] = add[rt], add[rt<<1|1] = add[rt];
        add[rt] = -1;
    }
    if(ql <= M) update(rt<<1, L, M, ql, qr, val);
    if(M + 1 <= qr) update(rt<<1|1, M + 1, R, ql, qr, val);
    push_up(rt);
}

ll _sum;
void query(int rt, int L, int R, int ql, int qr)
{
    if(ql <= L && R <= qr){
        _sum += sum[rt];
        return;
    }
    int M = (L + R) / 2;
    if(add[rt] != -1){
        sum[rt<<1] = (M - L + 1) * add[rt], sum[rt<<1|1] = (R - M) * add[rt];
        add[rt<<1] = add[rt], add[rt<<1|1] = add[rt];
        add[rt] = -1;
    }
    if(ql <= M) query(rt<<1, L, M, ql, qr);
    if(M + 1 <= qr) query(rt<<1|1, M + 1, R, ql, qr);
}

int n, q, ql[N], qr[N], spre[N];
char s[N], f[N];
int main()
{
    int T;
    scanf("%d", &T);
    while(T--){
        scanf("%d%d", &n, &q);
        for(int i = 1; i <= 4 * n; ++i){
            sum[i] = 0;
            add[i] = -1;
        }
        scanf("%s%s", s + 1, f + 1);

        for(int i = 1; i <= n; ++i){
            update(1, 1, n, i, i, f[i] - '0');
        }

        for(int i = 1; i <= q; ++i){
            scanf("%d%d", &ql[i], &qr[i]);
        }
        bool ok = 1;
        for(int i = q; i >= 1; --i){
            _sum = 0;
            query(1, 1, n, ql[i], qr[i]);
            if((qr[i] - ql[i] + 1) % 2 == 0 && _sum == (qr[i] - ql[i] + 1) / 2){
                ok = 0; break;
            }
            if(_sum <= (qr[i] - ql[i] + 1) / 2) update(1, 1, n, ql[i], qr[i], 0);
            else update(1, 1, n, ql[i], qr[i], 1);
        }
        for(int i = 1; i <= n; ++i){
            spre[i] = spre[i - 1] + (s[i] - '0');
            _sum = 0;
            query(1, 1, n, 1, i);
            ok &= (spre[i] == _sum);
        }
        puts(ok ? "YES" : "NO");
    }
}
```