#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
#define maxn 3e5+50

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

vector<vector<int>>adj;
vector<int>depth(maxn,0);
vector<ll>c(maxn,0);
void dfs(int v,int prev){
   for(auto i:adj[v]){
      if(i!=prev){
         depth[i] = depth[v]+1;
         c[i] += c[v];
         dfs(i,v);
      }
   }
}
void solve(){
     int n;cin >> n;
     vector<ll>a(n-1),b(n-1);
     adj.resize(n+1);
     for(int i = 0;i<n-1;i++){
        cin >> a[i] >> b[i];
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
     }
     dfs(1,0);
     int q;cin >> q;
     while(q--){
        ll t,e,x;cin >> t >> e >> x;e--;
        if(t==1){
            if(depth[a[e]]<depth[b[e]]){
                c[1] += x;
                c[b[e]] -= x;
            }
            else{
                c[a[e]]+=x;
            }
        }
        else{
            if(depth[b[e]]<depth[a[e]]){
                c[1] += x;
                c[a[e]] -= x;
            }
            else{
                c[b[e]] += x;
            }
        }
     }
     dfs(1,0);
     for(int i = 1;i<=n;i++) cout << c[i] <<'\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define replr(i, l, r) for (int i = (l); i < (r); ++i)
const int mod = 1e9 + 7;
vector<int> T[202020];
ll ans[202020], C[202020];
void rec(int x, ll c, int par) {
    c += C[x];
    for (int to : T[x]) {
        if (to == par)
            continue;
        rec(to, c, x);
    }
    ans[x] = c;
}

int main() {
    int n, q;
    cin >> n;
    vector<int> A(n), B(n), X(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        A[i] = a;
        B[i] = b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    queue<P> Q;
    Q.push({1, 0});
    while (!Q.empty()) {
        P p = Q.front();
        Q.pop();
        if (X[p.second] > 0)
            continue;
        X[p.second] = p.first;
        for (int to : T[p.second])
            Q.push({p.first + 1, to});
    }

    cin >> q;
    rep(i, q) {
        ll t, e, x;
        cin >> t >> e >> x;
        e--;
        int a = A[e], b = B[e];
        if (X[a] > X[b]) {
            if (t == 1)
                C[a] += x;
            else {
                C[0] += x;
                C[a] -= x;
            }
        } else {
            if (t == 1) {
                C[0] += x;
                C[b] -= x;
            } else
                C[b] += x;
        }
    }
    rec(0, 0, -1);
    rep(i, n) cout << ans[i] << endl;
    return 0;
}