//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize ("Ofast")

#include <bits/stdc++.h>
//#include <ctime>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 20;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int tree[4*MAXN], lazy[4*MAXN];
int n, q;

void build (int id = 1, int le = 1, int ri = n) {
    if (le == ri) {
        tree[id] = 0;
        lazy[id] = -1;
        return;
    }
    int mid = (le+ri)/2;
    build (2*id, le, mid);
    build (2*id+1, mid+1, ri);
    tree[id] = tree[2*id] + tree[2*id+1];
    lazy[id] = -1;
}

void shift (int id, int le, int ri) {
    if (lazy[id] == -1) return;
    //if (le == ri)
    int mid = (le+ri)/2;
    tree[2*id] = (mid-le + 1) * lazy[id];
    tree[2*id+1] = (ri - (mid+1) + 1) * lazy[id];
    lazy[2*id] = lazy[2*id+1] = lazy[id];
    lazy[id] = -1;
}

void upd (int x, int y, int v, int id = 1, int le = 1, int ri = n) {
    if (x > ri || y < le) return;
    if (x <= le && ri <= y) {
        lazy[id] = v;
        tree[id] = (ri-le+1) * v;
        return;
    }
    shift(id, le, ri);
    int mid = (le+ri)/2;
    upd (x, y, v, 2*id, le, mid);
    upd (x, y, v, 2*id+1, mid+1, ri);
    tree[id] = tree[2*id] + tree[2*id+1];
}

int get (int x, int y, int id = 1, int le = 1, int ri = n) {
    if (x > ri || y < le) return 0;
    if (x <= le && ri <= y) {
        return tree[id];
    }
    shift (id, le, ri);
    int mid = (le+ri)/2;
    return get(x,y, 2*id, le, mid) + get(x, y, 2*id+1, mid+1, ri);
}

string s, f;
vii ops;

int main()
{
    setIO();

    int t; cin >> t;
    while (t--) {
        cin >> n >> q >> s >> f;
        ops.clear();
        build();
        REP(q) {
            int x, y; cin >> x >> y;
            ops.pb({x,y});
        }
        FOR(i, 1, n) {
            upd (i, i, (f[i-1] == '1'));
        }
          // cout << " ";
          //  FOR(i, 1, n) cout << get(i, i);
          //  cout << endl;
        reverse(ops.begin(), ops.end());
        bool ok = true;
        for (auto p : ops) {
            int le = p.f, ri = p.s;
            int sum = get(le, ri);
            int sz = ri-le+1;
            if (sz%2 == 0 && sum == sz/2) {
                ok = false;
                break;
            }

            if (sum > sz/2)
                upd(le, ri, 1);
            else
                upd(le, ri, 0);

            //    cout << " ";
           // FOR(i, 1, n) cout << get(i, i);
            //scout << endl;
        }

        FOR(i, 1, n) {
            if (get(i, i) != (s[i-1]=='1'))
                ok = false;
        }
        if (ok) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}
