//#include <atcoder/all>
//using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) int(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t; cin >> t;
  while(t--){
    int n,a,b; cin >> n >> a >> b;
    if(n-a-b<0){
      cout << 0 << endl;
      continue;
    }

    mint ans = mint(n-a-b+2) * (n-a-b+1);
    ans = mint(n-a+1)*(n-b+1) - ans;
    ans *= ans;
    mint total = mint(n-a+1).pow(2) * mint(n-b+1).pow(2);
    cout << total - ans << endl;
  }

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,n) for(int i=x;i<(int)n;++i)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define out(a) cout<<a<<endl;
#define vout(v) rep(i,0,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vvout(vv) rep(j,0,vv.size()){vout(vv[j])}
#define mout(m) for(auto&e:m)cout<<e.first<<": "<<e.second<<endl;
#ifdef _CHK_
#define chk(a) if constexpr(_CHK_){cout<<#a<<": ";out(a)}
#define vchk(v) if constexpr(_CHK_){cout<<#v<<": ";vout(v)}
#define vvchk(vv) if constexpr(_CHK_){cout<<#vv<<": "<<endl;vvout(vv)}
#define mchk(m) if constexpr(_CHK_){cout<<#m<<": "<<endl;mout(m)}
#else
#define chk(a) {}
#define vchk(v) {}
#define vvchk(vv) {}
#define mchk(m) {}
#endif

vector<vector<int64_t>> adj;
vector<int64_t> depth;
vector<int64_t> imos;
vector<int64_t> score;

void get_score(int64_t now, int64_t prv, int64_t scr){
    scr += imos[now];
    score[now] = scr;
    for (auto& nxt: adj[now]) {
        if(nxt==prv) continue;
        get_score(nxt, now, scr);
    }
}

void get_depth(int64_t now, int64_t prv, int64_t dpt){
    depth[now] = dpt;
    for (auto& nxt: adj[now]) {
        if(nxt==prv) continue;
        get_depth(nxt, now, dpt+1);
    }
}

int main(){
    int64_t N;
    cin>>N;
    adj.resize(N);
    vector<int64_t> A(N);
    vector<int64_t> B(N);
    for(int i = 0 ; i < N-1 ; i++){
        int64_t a,b;
        cin>>a>>b;
        --a;--b;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
        A[i]=a;
        B[i]=b;
    }
    vvchk(adj)

    depth.resize(N);
    get_depth(0, -1, 0);
    vchk(depth)

    int64_t Q;
    cin>>Q;
    imos.resize(N);
    for(int i = 0 ; i < Q ; i++){
        int64_t t,e,x;
        cin>>t>>e>>x;
        --e;
        int64_t a=A[e], b=B[e];
        if(t==2) swap(a,b);
        if(depth[a]<depth[b]){
            imos[0]+=x;
            imos[b]-=x;
        }else{
            imos[a]+=x;
        }
    }
    vchk(imos)

    score.resize(N);
    get_score(0, -1, 0);
    for (auto& e: score) {
        out(e);
    }

    return 0;
}
