#include<bits/stdc++.h>

using namespace std;

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

    int n, m, tt;
    cin >> tt;

    while(tt--) {
        cin >> n >> m;

        vector<pair<int, int>> v1(m);

        for(int i = 0; i < m; i++)
            cin >> v1[i].first >> v1[i].second;

        if(m%2 == 1) {
            cout << "NO\n";
            continue;
        }

        sort(v1.begin(), v1.end(), [](const pair<int, int> x, const pair<int, int> y) {
            if(x.second != y.second)
                return x.second < y.second;
            return x.first < y.first;
        });

        bool pos = true;

        for(int i = 0; i < m && pos; i+=2) {
            int check = 0;

            if(v1[i+1].first == v1[i].first)
                check = 1;

            if((v1[i+1].second - v1[i].second)%2 != check)
                pos = false;
        }

        for(int i = 1; i < m-1 && pos; i+=2)
            if(v1[i].second == v1[i+1].second)    // cant be in the same column!
                pos = false;

        if(pos)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}
