#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    long long n;
    cin >> n;
    while (n--) {
        int m, u;
        cin >> m >> u;
        vector<pair<int, int>> arr(u);
        for (int i = 0; i < u; i++) {
            cin >> arr[i].second >> arr[i].first;
        }
        if (u % 2 == 1) {
            cout << "NO" << endl;
        } else {
            sort(arr.begin(), arr.end());
            while (true) {
                if (arr.empty()) {
                    cout << "YES" << endl;
                    break;
                } else {
                    if (arr[arr.size() - 1].first == arr[arr.size() - 2].first) {
                        arr.pop_back();
                        arr.pop_back();
                    } else {
                        if (arr[arr.size() - 1].first - arr[arr.size() - 2].first > 2) {
                            arr[arr.size() - 1].first -= ((arr[arr.size() - 1].first - arr[arr.size() - 2].first - 1) / 2) * 2;
                        } else {
                            if (arr[arr.size() - 1].first - arr[arr.size() - 2].first == 1) {
                                if (arr[arr.size() - 1].second != arr[arr.size() - 2].second) {
                                    cout << "NO" << endl;
                                    break;
                                } else {
                                    if (arr.size() == 2 || arr[arr.size() - 3].first != arr[arr.size() - 2].first) {
                                        arr.pop_back();
                                        arr.pop_back();
                                    } else {
                                        cout << "NO" << endl;
                                        break;
                                    }
                                }
                            } else {
                                arr[arr.size() - 1].first--;
                                if (arr[arr.size() - 1].second == 1) {
                                    arr[arr.size() - 1].second = 2;
                                } else {
                                    arr[arr.size() - 1].second = 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}