#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <set>
#define N 801000
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
	if (flag)	x = -x;
}
using namespace std;
int n, q;
struct node {
	int l, r;
	mutable int v;
	node(){}
	node(int jzp, int zzz, int lsr) { l = jzp, r = zzz, v = lsr; }
	inline bool operator <(const node &a) const {
		return l < a.l;
	}
};
set<node> st;
typedef set<node>::iterator iter;
inline iter Split(int x) {//[l,x),[x,r]
	if (x > n)	return st.end();
	iter it = --st.upper_bound(node(x, 0, 0));
	if (x == it->l)	return it;
	int l = it->l, r = it->r;
	int v = it->v;
	st.erase(it);
	st.insert(node(l, x - 1, v));
	return (st.insert(node(x, r, v))).first;
}
inline int query(int l, int r) {
	int res = 0;
	iter itr = Split(r + 1), itl = Split(l);
	for (iter it = itl; it != itr; ++it) res += (it->r - it->l + 1) * it->v;
	return res;
}
inline void Assign(int l, int r, int v) {//区间赋值
	iter itr = Split(r + 1), itl = Split(l);
	st.erase(itl, itr);
	st.insert(node(l, r, v));
}

char s[N], t[N];
int L[N], R[N];
inline bool check() {
	for (iter it = st.begin(); it != st.end(); ++it) {
		int l = it->l, r = it->r, v = it->v;
		for (int i = l; i <= r; ++i) if (s[i] - '0' != v)	return false;
	}
	return true;
}

void work() {
	read(n), read(q);
	scanf("%s", s + 1), scanf("%s", t + 1);
	for (int i = 1; i <= q; ++i) read(L[i]), read(R[i]);
	for (int i = 1; i <= n; ++i) st.insert(node(i, i, t[i] - '0'));
	for (int i = q; i; --i) {
		int cnt = query(L[i], R[i]);
		int len = R[i] - L[i] + 1;
		if (cnt * 2 == len) {
			puts("NO");
			return ;
		}
		if (cnt * 2 < len)	Assign(L[i], R[i], 0);
		else	Assign(L[i], R[i], 1);
	}
	puts(check() ? "YES" : "NO");
}

inline void clear() {
	st.clear();
}

int main() {
	int _; read(_);
	while (_--)	work(), clear();
	return 0;
}