func_code_string: #include <bits/stdc++.h>   using namespace std;      typedef long long ll;   typedef pair<ll,ll> pi;   typedef vector <ll> vi;   typedef vector <pi> vpi;   typedef pair<pi,ll> pii;   typedef set <ll> si;   typedef long double ld;   #define f first   #define s second   #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)   #define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)   #define pb push_back   #define all(x) (x).begin(), (x).end()   #define lbd(x, y) lower_bound(all(x), y)   #define ubd(x, y) upper_bound(all(x), y)   #define aFOR(i,x) for (auto i: x)   #define mem(x,i) memset(x,i,sizeof x)   #define fast ios_base::sync_with_stdio(false),cin.tie(0)      int N,Q,a,b;   string S,F;   struct node{    int s,e,m, val, lazy = 0, sz;    node *l,*r;    node (int ss,int ee){     s = ss; e = ee; m = (s+e) / 2; sz = e - s + 1;     if (s != e){      l = new node(s,m); r = new node(m+1,e);     }    }        void prop(){     if (lazy == 0 || s == e) return;     l->lazy = r->lazy = lazy;     l->val = lazy * l->sz; r->val = lazy * r->sz;     lazy = 0;    }        void upd(int a,int b,int c){     prop();     if (a <= s && e <= b){      lazy = c;      val = c * sz;     }else if (a > e || s > b) return;     else{      l->upd(a,b,c); r->upd(a,b,c);      val = l->val + r->val;     }    }        int qry(int a,int b){     prop();     if (a <= s && e <= b) return val;     else if (a > e || s > b) return 0;     else return l->qry(a,b) + r->qry(a,b);    }   }*root;      void solve(){    cin >> N >> Q >> S >> F;    swap(S,F);    root = new node(1,N);       FOR(i,0,N-1) root->upd(i + 1,i + 1, (S[i] ==  0  ? -1 : 1));        vpi v;    FOR(i,1,Q){     cin >> a >> b;     v.pb(pi(a,b));    }    reverse(all(v));    aFOR(i,v){     a = i.f, b = i.s;          int x = root->qry(a,b);     if (x == 0){      cout <<  NO n ; return;     }else if (x < 0) root->upd(a,b,-1);     else root->upd(a,b,1);    }    FOR(i,0,N-1){     if (root->qry(i+1,i+1) != (F[i] ==  0  ? -1 : 1)){      cout <<  NO n ; return;     }    }    cout <<  YES n ;   }   int main(){    fast;    int TC;    cin >> TC;    while (TC--) solve();   }      