#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<x<<"\n"

vector<pair<int,int> >vec;

int main(){
    ios::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    int T;cin>>T;
    while(T--){
        int n,m;cin>>n>>m;
        vec.clear();int a,b;
        for(int i=0;i<m;i++){
            cin>>a>>b;
            vec.push_back(make_pair(b,a));
        }
        if(m%2) {cout<<"NO\n";continue;}
        sort(vec.begin(),vec.end());
        bool f=true;
        for(int i=0;i<vec.size();i+=2){
            if(vec[i].se!=vec[i+1].se&&(vec[i+1].fi-vec[i].fi)%2==1) f=false;
            if(vec[i].se==vec[i+1].se&&(vec[i+1].fi-vec[i].fi)%2==0) f=false;
            if(i+2<vec.size()&&vec[i+1].fi==vec[i+2].fi) f=false;
        }
        cout<<(f?"YES":"NO")<<"\n";
    }
}
