
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n';

void solve(){
	ll n,m;
	cin >> n >> m;
	vector <pair<ll,ll>> v(m);
	for(ll i=0;i<m;i++){
		cin >> v[i].second >> v[i].first ;
	}
	sort(v.begin(),v.end());
	ll cur = 0;
	ll k = 0;
	for(ll i=0;i<m;i++){
		if(v[i].first-cur>2){
			if((v[i].first-cur)&1){
				k+=(v[i].first-cur-1);
			}
			else{
				k+=(v[i].first-cur-2);
			}
		}
		cur = v[i].first;
		v[i].first-=k;
	}
	n = v.back().first;
	vector < vector <char> > brute(3, vector <char> (n+1,'*'));
	for(auto x : v){
		brute[x.second][x.first] = '#';
	}
	bool isPossible = true;
	for(ll i=1;i<=n;i++){
		if(brute[1][i] == '*' && brute[2][i] == '*'){
			brute[1][i] = brute[2][i] = '#';
		}
		else if(brute[1][i] == '*'){
			if(i == n || brute[1][i+1] == '#'){
				isPossible = false;
				break;
			}
			else{
				brute[1][i+1] = brute[1][i] = '#';
			}
		}
		else if(brute[2][i] == '*'){
			if(i == n || brute[2][i+1] == '#'){
				isPossible = false;
				break;
			}
			else{
				brute[2][i+1] = brute[2][i] = '#';
			}
		}
	}
	cout << (isPossible?"YES":"NO") << endl;
	
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	cin >> tc;
	for(int i=1;i<=tc;i++){
		solve();
	}
	return 0;
}
