#include <bits/stdc++.h>

using namespace std;

void solve() {
	map <int, int> mp;
	int n, m, cnt = 0;
	cin >> n >> m;
	for (int i = 0, r, c; i < m; i++) {
		cin >> r >> c;
		mp[c] += (c + r) % 2 == 1? 1: -1;
	}
	mp[n + 1] = 0;
	for (auto [idx, val]: mp) {
		if (val == 0 && abs(cnt) > 0) {
			cout << "NO" << endl;
			return;
		}
		cnt += val;
		if (abs(cnt) == 2) {
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main() {
	int t; cin >> t;
	while (t--)
		solve();
}