#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
const int nmax=200005;
vector<vector<int>> g(nmax);
vector<ll> c(nmax),d(nmax);
void dfs(int cur,int pre=-1,ll res=0){
    c[cur]=res+d[cur];
    for(int to:g[cur]){
        if(to==pre) continue;
        dfs(to,cur,res+d[cur]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n-1),b(n-1);
    REP(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    vector<int> dis(n,inf);
    queue<int> qu;
    dis[0]=0;
    qu.push(0);
    while(!qu.empty()){
        int p=qu.front();
        qu.pop();
        for(int x:g[p]){
            if(dis[x]!=inf) continue;
            dis[x]=dis[p]+1;
            qu.push(x);
        }
    }
    int q;cin >> q;
    while(q--){
        int t,e,x;cin >> t >> e >> x;
        e--;
        if(t==1){
            if(dis[a[e]]<dis[b[e]]){
                d[0]+=x;
                d[b[e]]-=x;
            }
            else{
                d[a[e]]+=x;
            }
        }
        else{
            if(dis[a[e]]<dis[b[e]]){
                d[b[e]]+=x;
            }
            else{
                d[0]+=x;
                d[a[e]]-=x;
            }
        }
    }
    dfs(0);
    REP(i,n){
        cout << c[i] << endl;
    }
}
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define ll long long
  
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;

template<typename T>
void printv(vector<T> v) {
  for (auto e : v) {
    cout << e << " ";
  } cout << endl;
}
 
template<typename T>
void printvv(vector<T> vv) {
  for (int i=0; i<vv.size(); i++) {
    cout << i << ": ";
    for (auto e : vv[i]) {
      cout << e << " ";
    } cout << endl;
  }
}

///////////////////////////////////////////////////////////////////////


const int p = 1e9 + 7;

signed main() {
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  #endif
  ios_base::sync_with_stdio(false); 
  cin.tie(nullptr); 

  int t, n, a, b;
  cin >> t;
  while (t--) {
    cin >> n >> a >> b;

    if (n < a+b) {
      cout << 0 << endl;
      continue;
    }

    int x5 = (((n-a-b+1) * (n-a-b+2)) / 2 %p);
    // cout << "x5: " << x5 << endl;
    int x4 = ((((n-a+1) * (n-b+1))%p - (2 * x5)) + p) % p;
    int x3 = (x4 * x4) % p;
    
    int x1 = (n-a+1)*(n-a+1) % p;
    int x2 = (n-b+1)*(n-b+1) % p;
    int ans = ((((x1*x2) % p) - x3) % p + p) % p;

    cout << ans << endl;
    
    
    
  }
  
  
  return 0;
}