#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N = 2e5+5;

int t[4*N], p[4*N];
string s, f;

void push(int v, int tl, int tr) {
    if (tl == tr || p[v] == -1)
        return;
    int tm = tl+tr >> 1;
    int vv = v << 1;
    t[vv] = p[v]*(tm-tl+1);
    t[vv+1] = p[v]*(tr-tm);
    p[vv] = p[v];
    p[vv+1] = p[v];
    p[v] = -1;
}

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = f[tl]-'0';
        p[v] = -1;
        return;
    }
    int tm = tl+tr >> 1;
    int vv = v << 1;
    push(v, tl, tr);
    build(vv, tl, tm);
    build(vv+1, tm+1, tr);
    t[v] = t[vv]+t[vv+1];
}

void upd(int v, int tl, int tr, int l, int r, int val) {
    if (tl > r || l > tr)
        return;
    if (l <= tl && tr <= r) {
        t[v] = (tr-tl+1)*val;
        p[v] = val;
        return;
    }
    int tm = tl+tr >> 1;
    int vv = v << 1;
    push(v, tl, tr);
    upd(vv, tl, tm, l, r, val);
    upd(vv+1, tm+1, tr, l, r, val);
    t[v] = t[vv]+t[vv+1];
}

int get(int v, int tl, int tr, int l, int r) {
    if (l > tr || tl > r)
        return 0;
    if (l <= tl && tr <= r)
        return t[v];
    int tm = tl+tr >> 1;
    int vv = v << 1;
    push(v, tl, tr);
    return get(vv, tl, tm, l, r)+get(vv+1, tm+1, tr, l, r);
}



void solve() {
    int n, q; cin >> n >> q;
    cin >> s >> f;
    s = "#"+s, f = "#"+f;
    vii ask(q);
    for (pii& cur : ask)
        cin >> cur.x >> cur.y;
    reverse(all(ask));
    build(1, 1, n);
    for (pii cur : ask) {
        int sum = get(1, 1, n, cur.x, cur.y);
        int len = cur.y-cur.x+1;
        if (sum*2 == len) {
            cout << "NO\n";
            return;
        }
        if (sum <= (len-1)/2) {
            upd(1, 1, n, cur.x, cur.y, 0);
        }
        else {
            upd(1, 1, n, cur.x, cur.y, 1);
        }
    }
    for (int i=1; i<=n; ++i) {
        if (get(1, 1, n, i, i)+'0' != s[i]) {
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";
}



int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t; cin >> t;
    while(t--) solve();
}
