#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1> 
void print(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1> 
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1> 
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 1000001
#define MOD 1000000007ll
struct RangeTree {
    int size;
    vector<ll> S;
    vector<ll> P;
    RangeTree(int size) {
        this->size = size;
        S.resize(5 * size);
        P.resize(5 * size);
    }

    void create(int i, ll a, ll b, const string &s) {
        P[i] = -1;
        if (a == b) {
            S[i] = (s[a] - '0');
            return;
        }
        ll m = (a + b) / 2;
        create(2 * i + 1, a, m, s);
        create(2 * i + 2, m + 1, b, s);
        S[i] = S[2 * i + 1] + S[2 * i + 2];
    }

    void prop(int i, ll a, ll b) {
        if (P[i] == -1) return;
        if (a != b) {
            P[2 * i + 1] = P[2 * i + 2] = P[i];
            ll m = (a + b) / 2;
            S[2 * i + 1] = (m - a + 1) * P[i];
            S[2 * i + 2] = (b - m) * P[i];
            S[i] = S[2 * i + 1] + S[2 * i + 2];
        }
        P[i] = -1;
    }

    void set(int i, ll a, ll b, const int &ra ,const int &rb, int v) {
        if (ra > b || rb < a) return;
        if (ra <= a && b <= rb) {
            S[i] = v * (b - a + 1);
            P[i] = v;
            return;
        }
        ll m = (a+b)/2;
        prop(i, a, b);
        set(2 * i + 1, a, m, ra, rb, v);
        set(2 * i + 2, m+1, b, ra, rb, v);
        S[i] = S[2 * i + 1] + S[2 * i + 2];
    }

    ll get(int i, ll a, ll b, const int &ra ,const int &rb) {
        if (ra > b || rb < a) return 0;
        if (ra <= a && b <= rb) {
            return S[i];
        }
        prop(i, a, b);
        ll m = (a+b)/2;
        return get(2 * i + 1, a, m, ra, rb) +
            get(2 * i + 2, m+1, b, ra, rb);
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    string s, t;
    cin >> s >> t;
    RangeTree T(n);
    T.create(0, 0, n - 1, t);
    vector<pair<int, int>> Q(q);
    rep(i,q) cin >> Q[i].first >> Q[i].second;
    reverse(all(Q));
    rep(i, q) {
        int a = Q[i].first - 1;
        int b = Q[i].second - 1;

        int o = T.get(0, 0, n-1, a, b);
        int c = (b - a + 1) - o;
        if (c == o) 
            out("NO");
        T.set(0, 0, n-1,a, b, c > o ? 0 : 1);
    }
    rep(i, n) {
        int v = T.get(0,0, n-1, i, i);
        if (v != (s[i]-'0'))
            out("NO");
    }
    out("YES");
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
    cin >> test;    
    rep(testCase, test) {
        #ifdef _OLIMPOLOCAL
            cout << "------------------ TESTCASE: " << testCase << " -------------\n";
        #endif
        solve();
    }
    return 0;
}


