#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vecctor<ll>>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define all(v) v.begin(),v.end()



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll mod = 1e9+7;

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    rep(i,t){
        ll n,a,b;
        cin >> n >> a >> b;
        if(a+b > n){
            cout << 0 << endl;
            continue;
        }
        ll ans = 1;
        ll x = ((n-a-b+2)%mod)*((n-a-b+1)%mod)%mod;
        ans *= x;
        ans = ans*(n-a+1)%mod;
        ans = ans *(n-b+1)%mod;
        ans = ans*2%mod;
        ans -= x*x%mod;
        ans = (ans +mod)%mod;
        cout << ans << endl;

    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define io ios::sync_with_stdio(false); cin.tie(0)

struct edge { int to; ll cost; };

struct graph{
    int V;
    vector<vector<edge>> G;
    vector<ll> path;

    graph(int n): V(n) { 
        G.resize(V);
        path.resize(V);
        fill(path.begin(), path.end(), -1);
    }

    void add_edge(int s, int t, ll cost) {
        edge e;
        e.to = t; e.cost = cost;
        G[s].push_back(e);
    }

    // Compute the shortest path starting from s using Dijkstra algorithm
    int dijkstra(int s) {
        priority_queue<P, vector<P>, greater<P>> que; // min-heap of (cost, vertex)
        for (auto e : G[s]) {
            que.emplace(e.cost, e.to);
        }
        while (que.size()) {
            P p = que.top(); que.pop();
            int c = p.first, v = p.second;
            if (v == s) return c;
            if (path[v] < s) {
                path[v] = s;
                for (auto e : G[v]) {
                    que.emplace(c + e.cost, e.to);
                }
            }
        }
        return -1;
    }
};

int main()
{
    io;
    int n, m;
    cin >> n >> m;
    graph g(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
    }
    rep(i, n) {
        cout << g.dijkstra(i) << endl;
    }
    return 0;
}