#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;
/*
typedef __int128_t i128;
typedef __float128 f128;

string tostring(i128 x) {
	string s;
	if (x == 0) return "0";
	bool pos = true;
	if (x < 0) {
		pos = false;
		x = -x;
	}
	while (x) {
		s.pb((char) (x % 10 + '0'));
		x /= 10;
	}
	if (!pos) s.pb('-');
	reverse(s.begin(), s.end());
	return s;
}

void print(i128 x) {
	printf("%s", tostring(x).c_str());
}
*/

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int INF = 1e9 + 41;
const int MAX = 2e5 + 41;

int n, q;
int l[MAX];
int r[MAX];
char s[MAX];
char f[MAX];
int t[MAX * 4];
int lz[MAX * 4];

void push(int x, int tl, int tr) {
	if (lz[x] != -1) {
		if (x * 2 + 1 < MAX * 4) {
			lz[x * 2 + 1] = lz[x];			
		}
		if (x * 2 + 2 < MAX * 4) {
			lz[x * 2 + 2] = lz[x];			
		}
		t[x] = (tr - tl + 1) * lz[x];
		lz[x] = -1;		
	}
}

int getval(int x, int tl, int tr) {
	if (lz[x] == -1) {
		return t[x];
	} else {
		return (tr - tl + 1) * lz[x];
	}	
}

void build(int x = 0, int tl = 1, int tr = n) {
	lz[x] = -1;
	if (tl == tr) {
		t[x] = f[tl] - '0';		
	} else {
		int tm = (tl + tr) / 2;
		build(x * 2 + 1, tl, tm);
		build(x * 2 + 2, tm + 1, tr);
		t[x] = t[x * 2 + 1] + t[x * 2 + 2];
	}
}

int getsum(int x, int tl, int tr, int l, int r) {
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) {
		return getval(x, tl, tr);
	}
	push(x, tl, tr);
	int tm = (tl + tr) / 2;
	int v1 = getsum(x * 2 + 1, tl, tm, l, r);
	int v2 = getsum(x * 2 + 2, tm + 1, tr, l, r);
	t[x] = getval(x * 2 + 1, tl, tm) + getval(x * 2 + 2, tm + 1, tr);
	return v1 + v2;
}

void setval(int x, int tl, int tr, int l, int r, int val) {
	if (tl > r || tr < l) return;
	if (l <= tl && tr <= r) {
		lz[x] = val;
		return;
	}
	push(x, tl, tr);
	int tm = (tl + tr) / 2;
	setval(x * 2 + 1, tl, tm, l, r, val);
	setval(x * 2 + 2, tm + 1, tr, l, r, val);
	t[x] = getval(x * 2 + 1, tl, tm) + getval(x * 2 + 2, tm + 1, tr);
}


void solve () {
	build();
	/*fi(1, n) {
		err("l = 1 r = %d sum = %d\n", i, getsum(0, 1, n, 1, i));
	}*/
	bool ok = true;
	fdo(q, 1) {
		/*err("before = ");
		fi(1, n) {
			err("%d",getsum(0, 1, n, i, i));
		}
		err("\n");*/

		int l = ::l[o];
		int r = ::r[o];
		int all = r - l + 1;
		int can = (all - 1) / 2;		
		int q1 = getsum(0, 1, n, l, r);
		int q0 = all - q1;
		//err("o = %d l = %d r = %d all = %d q0 = %d q1 = %d\n", o, l, r, all, q0, q1);
		if (q0 <= can) {			
			setval(0, 1, n, l, r, 1);			
		} else if (q1 <= can) {
			setval(0, 1, n, l, r, 0);
		} else {
			ok = false;
			//err("ok = %d o = %d\n", ok, o);
			break;
		}
	}
	if (ok) {
		fi(1, n) {
			int want = s[i] - '0';
			int have = getsum(0, 1, n, i, i);
			if (want != have) {
				ok = false;				
				break;
			}			
		}
	}
	//err("ok = %d\n", ok);
	if (ok) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif	
	
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d %d\n", &n, &q);
		scanf("%s\n%s\n", s + 1, f + 1);
		fi(1, q) scanf("%d %d\n", &l[i], &r[i]);
		//err("f = %s s = %s\n", f + 1, s + 1);
		solve();
	}

	exit();
	return 0;
}



