#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
using namespace std;

const int INFINT = 2e9;
const ll INFLL = 2e18;

void solve() {
    ll N; int M; cin >> N >> M;
    vector<pair<ll, int>> V;
    for (int i=0; i<M; i++) {
        int r; ll n; cin >> r >> n;
        V.push_back({n, r-1});
    }
    sort(V.begin(), V.end());

    bool ok = true;
    int bit = 0;
    ll t = 0;
    for (int i=0; i<M; i++) {
        int r = V[i].second;
        ll c = V[i].first;
        int d = c-t;
        if (bit) {

            int f = (d%2)^r;
            if (((1<<f)&bit) == 0) {
                bit = 0;
            } else {
                ok = false;
                break;
            }
        } else {
            if (d == 0) {
                ok = false;
                break;
            }
            bit |= (1<<r);
        }
        t = c;
    }

    if (bit) ok = false;

    cout << (ok ? "YES" : "NO") << endl;

    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int Q; cin >> Q;
    for (int q=0; q<Q; q++) {
        solve();
    }
}