#include <bits/stdc++.h>

using namespace std ;

#define i64 int64_t // typecast using i64(x)
#define int int64_t 
#define ld long double
#define endl "\n"
#define f(i,a,b) for(int i=int(a);i<int(b);++i)

#define pr pair
#define ar array
#define fr first
#define sc second
#define vt vector
#define pb push_back
#define LB lower_bound  
#define UB upper_bound
#define PQ priority_queue

#define sz(x) ((int)(x).size())
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))

// Input functions
// Use only for reading int, vectors.
// Be careful that it reads the complete vector.
template<class A> void rd(vt<A>& v);
template<class T> void rd(T& x){ cin >> x; }
template<class H, class... T> void rd(H& h, T&... t) { rd(h) ; rd(t...) ;}
template<class A> void rd(vt<A>& x) { for(auto& a : x) rd(a) ;}

// DEBUG functions
template<typename T>
void __p(T a) {
  cout<<a; 
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}\n"; 
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}\n"[it+1==a.end()]; 
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}

//Fast input output
void setIO(string s = "") {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  cin.exceptions(cin.failbit); 
  if(sz(s)){
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
  }
}
template<class T> struct SEGTREE { 
  public:
    const T ID = 0, NEUTRAL_ELEMENT = 0, NO_OPERATION = -1; // set this accordingly
    int size ;
    vector<T> seg, ops ;
    /*T modify_op(T a,T b){ // set this accordingly too modifiction done on array 
      if(b == NO_OPERATION) return a ;
      return b ;
    }  
    T calc_op(T a,T b){ // set this accordingly too what is asked on array 
      return a + b  ;
    }
    void apply_op(T &a,T b){
      a = modify_op(a, b) ;
    }*/
    void propogate(int x,int rx,int lx){
      if(rx - lx == 1 or ops[x] == NO_OPERATION) return ;
      int mid = (rx + lx)/2 ;
      seg[2 * x + 1] = ops[x] * (mid - lx)  ;
      seg[2 * x + 2] = ops[x] * (rx - mid)  ; 
      ops[2 * x + 1] = ops[x] ;
      ops[2 * x + 2] = ops[x] ; 
      ops[x] = NO_OPERATION ;
    }
    void init(int n){ 
      size = 1 ;
      while(size < n) size *= 2 ;
      seg.assign(2*size, ID) ; // get the intial segment tree also ie we may need to build it seperately
      ops.assign(2*size, NO_OPERATION) ; 
    }
    void modify(int l, int r, int x, int lx, int rx, T v) { // modify on interval [l, r)
      propogate(x, rx, lx) ;
      if( lx >= r || l >= rx ){
        return ;
      }
      if( lx >= l && rx <= r){
        ops[x] = v ; seg[x] = v * (rx - lx) ; return ;
      }
      int mid = (rx + lx)/2 ;
      modify(l, r, 2 * x + 1, lx, mid, v); 
      modify(l, r, 2 * x + 2, mid, rx, v); 
      seg[x] = seg[2 * x + 1] + seg[2 * x + 2] ;
      return ;
    }
    void modify(int l, int r, T v) { // modify on interval [l, r)
      modify(l, r, 0, 0, size, v) ; return ;
    }
    T get(int l, int r, int x, int lx, int rx) { // get val at range [l, r)
      propogate(x, rx, lx) ;
      if( lx >= r || l >= rx ){
        return NEUTRAL_ELEMENT ;
      }
      if( lx >= l && rx <= r){
        return seg[x] ;
      }
      int mid = (rx + lx)/2 ;
      T temp1 = get(l, r, 2 * x + 1, lx, mid) ;
      T temp2 = get(l, r, 2 * x + 2, mid, rx) ;
      T res = temp1 + temp2 ;
      return res ;
    }
    T get(int l, int r) { // get val at range [l, r)
      return get(l, r, 0, 0, size) ;
    }
};

void solve(){
  int n, q; rd(n,q);
  string s, t ; rd(s,t) ;
  vector<int> L(q), R(q) ;
  f(i,0,q) rd(L[i],R[i]) ;
  SEGTREE<int> st ;
  st.init(n) ;
  f(i,0,n){
    st.modify(i,i+1,t[i]-'0') ;
  }
  for(int j = q-1; j >= 0; --j){
    int l = L[j]-1, r = R[j] ;
    int temp = st.get(l,r) ;
    if(temp<(r-l+1)/2){
      st.modify(l,r,0) ;
    }else if(temp>(r-l)/2){
      st.modify(l,r,1) ;
    }else{
      cout << "NO" << endl ; return ;
    }
  }
  f(i,0,n){
    int temp = st.get(i,i+1) ;
    if(temp != int(s[i]-'0')){
      cout << "NO" << endl ; return ;
    }
  }
  cout << "YES" << endl ;

}
signed main(){
  setIO() ;
  int T ; rd(T) ;
  f(_,0,T){
    solve() ;
  }
}