#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
#define endl '\n'
#define lowbit(x) (x & -x)
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define ck(x) (x >= mod ? x - mod : x)
#define inf 0x3f3f3f3f
#define eps 1e-6
#define maxn 400200
#define maxm 10000100
#define G 3
#define invG 332748118
const int mod = 1e7 + 7;
const double PI = 4 * atan2(1.0, 1.0);
int t, n, q, l[maxn], r[maxn], v[maxn << 2], lazy[maxn << 2], cnt;
char s[maxn], f[maxn];
void pushup(int x) {
    v[x] = v[ls(x)] + v[rs(x)];
}
void build(int x, int l, int r) {
    if (l == r) {
        v[x] = f[l] - '0';
        lazy[x] = 0;
        return;
    }
    int mid = (l + r) >> 1;
    build(ls(x), l, mid);
    build(rs(x), mid + 1, r);
    pushup(x);
    lazy[x] = 0;
}
void F(int x, int l, int r, int k) {
    lazy[x] = k;
    v[x] = (r - l + 1) * (k - 1);
}
void pushdown(int x, int l, int r) {
    if (lazy[x] == 0) return;
    int mid = (l + r) >> 1;
    F(ls(x), l, mid, lazy[x]);
    F(rs(x), mid + 1, r, lazy[x]);
    lazy[x] = 0;
}
int query(int x, int nl, int nr, int l, int r) {
    int ret = 0;
    if (nl <= l && r <= nr)return v[x];
    pushdown(x, l, r);
    int mid = (l + r) >> 1;
    if (nl <= mid) ret += query(ls(x), nl, nr, l, mid);
    if (nr > mid) ret += query(rs(x), nl, nr, mid + 1, r);
    return ret;
}
void update(int x, int nl, int nr, int l, int r, int k) {
    //cout << x << ' ' << nl << ' ' << nr << ' ' << l << ' ' << r << endl;
    if (nl <= l && r <= nr) {
        v[x] = (k - 1) * (r - l + 1);
        lazy[x] = k;
        return;
    }
    pushdown(x, l, r);
    int mid = (l + r) >> 1;
    if (nl <= mid) update(ls(x), nl, nr, l, mid, k);
    if (nr > mid) update(rs(x), nl, nr, mid + 1, r, k);
    pushup(x);
}
void check(int x, int l, int r) {
    if (l == r) {
        if (v[x] == s[l] - '0')cnt++;
        //cout << v[x];
        return;
    }
    int mid = (l + r) >> 1;
    pushdown(x, l, r);
    check(ls(x), l, mid);
    check(rs(x), mid + 1, r);
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> t;
    while (t--) {
        cin >> n >> q;
        cin >> s + 1;
        cin >> f + 1;
        for (int i = 1; i <= q; i++) {
            cin >> l[i] >> r[i];
        }
        build(1, 1, n);
        for (int i = q; i >= 1; i--) {
//            check(1, 1, n);
//            cout << endl;
            int sum = query(1, l[i], r[i], 1, n);
            int x = (r[i] - l[i]) / 2;
            //cout << i << ' ' << l[i] << ' ' << r[i] << ' ' << sum << ' ' << x << ' ' << r[i] - l[i] + 1 - sum << endl;
            if (sum > x && r[i] - l[i] + 1 - sum > x) {
                cout << "NO" << endl;
                goto nxt;
            }
            if (sum <= x) {
                //cout << "111" << endl;
                update(1, l[i], r[i], 1, n, 1);
            } else {
                //cout << "222" << endl;
                update(1, l[i], r[i], 1, n, 2);
            }
        }
        cnt = 0;
        check(1, 1, n);
        if (cnt != n) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
        nxt:;
    }
    return 0;
}