#include <cstdio>
#include <algorithm>
#include <vector>

#define fir first
#define sec second

using namespace std;

typedef pair<int, int> PII;

void solve() {
	int n, m;
	
	scanf("%d%d", &n, &m);
	
	vector<PII> g(m);
	
	for (auto &[x, y] : g)
		scanf("%d%d", &y, &x);
		
	sort(g.begin(), g.end());
	
	if (m & 1) {
		printf("NO\n");
		
		return;
	}
	
	for (int i = 0; i < m; i += 2) {
		if (g[i].sec == g[i + 1].sec && (g[i + 1].fir - g[i].fir) % 2 == 0) {
			printf("NO\n");
			
			return;
		}
		if (g[i].sec + g[i + 1].sec == 3 && (g[i + 1].fir - g[i].fir) % 2 != 0) {
			printf("NO\n");
			
			return;
		}
		if (i + 2 < m && g[i + 1].fir == g[i + 2].fir) {
		    printf("NO\n");
		    
		    return;
		}
	}
	
	printf("YES\n");
}

int main() {
	int T;
	scanf("%d", &T);
	
	while (T -- )
		solve();
		
	return 0;
}