#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

#define DIVIDER 1000000007LL

ll solve(ll N, ll A, ll B) {
  if (A + B > N) {
    return 0;
  }

  ll retv = (((N - A + 1) * (N - A + 1)) % DIVIDER) *
            (((N - B + 1) * (N - B + 1)) % DIVIDER);
  retv %= DIVIDER;

  ll x = (N - A + 1) * (N - B + 1) - (N - A - B + 1) * (N - A - B + 2);
  x = x % DIVIDER;
  retv = (retv - ((x * x) % DIVIDER) + DIVIDER) % DIVIDER;
  return retv;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int T;
  cin >> T;

  // main procedure
  vector<ll> ans;
  for (size_t i = 0; i < T; i++) {
    ll N, A, B;
    cin >> N >> A >> B;
    ans.push_back(solve(N, A, B));
  }

  // output
  for (size_t i = 0; i < T; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

ll sum = 0;
ll dd[200000];
ll ans[200000];
vector<int> v[200000];
int p[200000];
pii ed[200000];
// 여기를 루트로 하는 애들..

void pre(int o, int pa) {
    p[o] = pa;
    for (int i : v[o]) {
        if (i == pa) continue;
        pre(i, o);
    }
}

void go(int o, int pa, ll ss) {
    ss += dd[o];
    ans[o] = sum + ss;

    for (int i : v[o]) {
        if (i == pa) continue;
        go(i, o, ss);
    }
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        ed[i] = {a, b};
        v[a].push_back(b);
        v[b].push_back(a);
    }
    pre(0, 0);

    int q;
    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        int a,b,c;
        scanf("%d %d %d", &a, &b, &c);
        b--;

        if (a == 1) {
            if (p[ed[b].second] == ed[b].first) {
                sum += c;
                dd[ed[b].second] -= c;
            }
            else dd[ed[b].first] += c;
        }
        else {
            if (p[ed[b].first] == ed[b].second) {
                sum += c;
                dd[ed[b].first] -= c;
            }
            else dd[ed[b].second] += c;
        }
    }

    go(0, 0, 0);
    for (int i = 0; i < n; i++) printf("%lld\n", ans[i]);
}

// author: rdd6584