#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

template<int64_t M = 1000000007>
class ModInt {
public:
	ModInt() : val_(0) {};

	ModInt(int64_t val) {
		this->val_ = val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
		while (this->val_ < 0)  this->val_ += M;
	}

	operator int64_t() const {
		return this->val_;
	}

	ModInt& operator += (int64_t val) {
		this->val_ += val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
		while (this->val_ < 0) this->val_ += M;

		return *this;
	}

	ModInt& operator -= (int64_t val) {
		this->val_ -= val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
		while (this->val_ < 0) this->val_ += M;

		return *this;
	}

	ModInt& operator *= (int64_t val) {
		this->val_ *= val;
		this->val_ %= M;

		return *this;
	}

	ModInt& operator /= (int64_t val) {
		ModInt v = ModInt::pow(val, M - 2);
		*this *= v;

		return *this;
	}

	ModInt& operator += (int32_t val) {
		return this->operator+=((int64_t)val);
	}

	ModInt& operator -= (int32_t val) {
		return this->operator-=((int64_t)val);
	}

	ModInt& operator *= (int32_t val) {
		return this->operator*=((int64_t)val);
	}

	ModInt& operator /= (int32_t val) {
		return this->operator/=((int64_t)val);
	}

	ModInt operator + (int64_t v) const {
		ModInt ret = *this;
		return (ret += v);
	}

	ModInt operator - (int64_t v) const {
		ModInt ret = *this;
		return (ret -= v);
	}

	ModInt operator * (int64_t v) const {
		ModInt ret = *this;
		return (ret *= v);
	}

	ModInt operator / (int64_t v) const {
		ModInt ret = *this;
		return (ret /= v);
	}

	ModInt operator + (int32_t v) const {
		return this->operator+((int64_t)v);
	}

	ModInt operator - (int32_t v) const {
		return this->operator-((int64_t)v);
	}

	ModInt operator * (int32_t v) const {
		return this->operator*((int64_t)v);
	}

	ModInt operator / (int32_t v) const {
		return this->operator/((int64_t)v);
	}

	static ModInt pow(ModInt n, int64_t m) {
		if (m == 0) {
			ModInt ret(1);
			return ret;
		}
		if (m == 1) {
			return n;
		}

		ModInt v = pow(n, m / 2);
		ModInt ret = v * v;
		if (m & 1) {
			ret *= n;
		}
		return ret;
	}

	ostream& operator << (ostream& out) {
		out << this->val_;
		return out;
	}

private:
	int64_t val_;
};

void solve()
{
	int64_t n, a, b; cin >> n >> a >> b;
	ModInt<> t = n - a + 1;
	ModInt<> u = n - b + 1;
	ModInt<> v = max(n - a - b + 1, (int64_t)0);

	ModInt<> x = t * u - v * (v + 1);
	ModInt<> y = t * t * u * u - x * x;
	cout << y << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int t; cin >> t;
	REP(t) {
		solve();
	}

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<int,int,int>
using Graph = vector<vector<int>>;

ll mod = 998244353;

int main() {
    ll N,M; cin >> N >> M;
    vector<Pr> br;
    rep(i,M){
        ll x,y; cin >> x >> y;
        br.push_back(make_pair(x,y));
    }
    sort(br.begin(),br.end());
    set<ll> can,temp; can.insert(N);
    ll nx = 0;
    rep(i,M){
        ll x = br[i].first; ll y = br[i].second;
        if(x!=nx){
            temp.clear(); nx = x;
        }
        bool en = false;
        rep(j,3){
            if(j==1) continue;
            if(can.count(y-1+j)){
                if(temp.count(y-1+j)) continue;
                en = true;
                if(can.count(y)) continue;
                can.insert(y); temp.insert(y);
            }
            else{
                if(!temp.count(y-1+j)) continue;
                en = true;
                if(can.count(y)) continue;
                can.insert(y); temp.insert(y);
            }
        }
        if(en) continue;
        if(can.count(y)){
            can.erase(y); temp.insert(y);
        }
    }
    //for(ll x:can) cout << x << endl;
    cout << can.size() << endl;
}