#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define hash hash1
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R)
{
     int val = rng() % R;
     assert(val >= 0);
     return val;
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
int32_t MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------

int solve(int i,int mask,int n,vector<vector<int>>& v,vector<vector<int>>& dp)
{
      if(i==n)return (mask==0||mask==3);
      if(dp[i][mask]!=-1)return dp[i][mask];
            
      int block0=(mask&1);
      int block1=((mask&2)>0);
      
      dp[i][mask]=0;

      if(block0 && block1) return dp[i][mask]=solve(i+1,v[i+1][0]+2*v[i+1][1],n,v,dp);
      if((!block0) && block1 && v[i+1][0])return dp[i][mask]=0;
      if((!block1) && block0 && v[i+1][1])return dp[i][mask]=0;
      
      if(!block0 && !block1)
      {
           if(v[i+1][0] || v[i+1][1])
           dp[i][mask]|=solve(i+1,v[i+1][0]+2*v[i+1][1],n,v,dp);
           else
           {
                dp[i][mask]|=solve(i+1,0,n,v,dp);
                dp[i][mask]|=solve(i+1,3,n,v,dp);
           }
      }
      else if(!block0)
      dp[i][mask]|=solve(i+1,1+2*v[i+1][1],n,v,dp);
      else
      {
           assert(!block1 && block0);
           dp[i][mask]|=solve(i+1,v[i+1][0]+2,n,v,dp);
      }
      


      return dp[i][mask];
}

int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     cin >> tests;
     rep(ii, 0, tests)
     {
          int n,m;
          cin>>n>>m;
          map<int,bool> check;
          map<pii,bool> blocked;
          set<int> s;
          map<int,int> map;
          int cur=1;

          vector<vector<int>> v(4*m+15,vector<int>(2,0));
          vector<vector<int>> dp(4*m+5,vector<int>(4,-1));
          vector<pii> vals;
          rep(i,0,m)
          {
               int r,c;
               cin>>r>>c;
               vals.push_back({r,c});
               blocked[{c,r}]=true;
               s.insert(c);
          }

          vector<int> unique_vals;
          for(auto it:s)unique_vals.push_back(it);
          int siz=s.size(); 

          rep(i,0,unique_vals.size())
          {
               int it=unique_vals[i];
               int nxt=unique_vals[i+1];
               int num=1;
               if(nxt-it-1<=num)num=nxt-it-1;
               else if((nxt-it-1)%2==0)num=2;
               map[it]=cur++;
               rep(j,1,num+1)map[it+j]=cur++;
          }

          for(auto it:blocked)v[map[it.f.f]][it.f.s-1]=1;
          n=cur-1;

          
          cout<<(solve(1,v[1][0]+2*v[1][1],n,v,dp)==1?"YES":"NO")<<endl;
          
     }
    
     return 0;
}