#include<bits/stdc++.h>
using namespace std;
#define ll long long int

bool cmp(array<ll,2> a,array<ll,2> b){
    if(a[1]!=b[1]){
        return a[1]<b[1];
    }
    return a[0]<b[0];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;

    while(t--){
        ll n,m;
        cin>>n>>m;

        vector<array<ll,2>> v;
        for(ll i=0;i<m;i++){
            ll r,c;
            cin>>r>>c;
            v.push_back({r,c});
        }

        sort(v.begin(),v.end(),cmp);
        ll i1=1;
        ll i2=1;
        ll i=0;
        bool flg=1;
        while(i<m){
            //cout<<i1<<" "<<i2<<" "<<v[i][0]<<" "<<v[i][1]<<"\n";
            if(i==m-1){
                if(i1==i2){
                    flg=0;
                    break;
                }
                if(v[i][0]==1 && (v[i][1]-i1)%2){
                    flg=0;
                    break;
                }
                if(v[i][0]==2 && (v[i][1]-i2)%2){
                    flg=0;
                    break;
                }
                i++;
            }
            else if(v[i][1]==v[i+1][1] && v[i+1][0]==1+v[i][0]){
                if(i1!=i2){
                    flg=0;
                    break;
                }
                i1=v[i][1]+1;
                i2=v[i][1]+1;
                i+=2;
            }
            else if(v[i][0]==1){
                if(i1==i2){
                    i1=v[i][1]+1;
                    i2=v[i][1];
                }
                else if((v[i][1]-i1)%2==0){
                   i1=v[i][1]+1;
                   i2=v[i][1]+1;
                }
                else if((v[i][1]-i1)%2==1){
                    flg=0;
                    break;
                }
                i++;
            }
            else if(v[i][0]==2){
                if(i1==i2){
                    i1=v[i][1];
                    i2=v[i][1]+1;
                }
                else if((v[i][1]-i2)%2==0){
                   i1=v[i][1]+1;
                   i2=v[i][1]+1;
                }
                else if((v[i][1]-i2)%2==1){
                    flg=0;
                    break;
                }
                i++;
            }
        }
        if(flg){
            cout<<"YES"<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }

    }
}