#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define v(a, n) vector<int> a(n, 0)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define print(v) rep(i, (int)v.size()) cout << v[i] << (i+1 == (int)v.size() ? "\n" : " ");
#define rfor(i, a, b) for (int i = a; i < b; i++)
const vector<int> maze = {0, 1, 0, -1, 0};
const int mod = 1e9+7;
ll gcd(ll a, ll b) {return b == 0 ? abs(a) : gcd(b, a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a, b);}
ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1; y = 0;
    return a;
  } else {
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
  }
}
ll modpow(ll x, ll n, ll p) {
  ll ans = 1;
  while (n > 0) {
    if (n&1) ans = ans*x%p;
    x = x*x%p;
    n >>= 1;
  }
  return ans;
}
vector<vector<int>> g;
vector<int> depth;
void dfs(int par, int son){depth[son]=depth[par]+1;for(int i : g[son]){if(i==par)continue;dfs(son, i);}}

int main() {int n; cin >>n;vector<pair<int, int>>edge(n-1);g.resize(n);rep(i,n-1){int a,b;cin>>a>>b;a--;b--;edge[i].F=a;edge[i].S=b;g[a].push_back(b);g[b].push_back(a);}int q;cin>>q;vector<vector<int>> query(q,vector<int>(3));rep(i,q)cin>>query[i][0]>>query[i][1]>>query[i][2];depth.resize(n);depth[0]=0;for(int i : g[0])dfs(0,i);vector<ll> cnt(n,0);rep(i,q){int t=query[i][0],c=query[i][2];int a,b;if(t==1){a=edge[query[i][1]-1].F;b=edge[query[i][1]-1].S;}else{a=edge[query[i][1]-1].S;b=edge[query[i][1]-1].F;}if(depth[a]<depth[b]){cnt[0]+=c;cnt[b]-=c;}else{cnt[a]+=c;}}vector<bool> seen(n,false);seen[0]=true;vector<ll> ans(n, 0);ans[0]=cnt[0];queue<int> que;que.push(0);while(!que.empty()){int x=que.front();que.pop();for(int i:g[x]){if(seen[i])continue;seen[i]=true;ans[i]=ans[x]+cnt[i];que.push(i);}}print(ans);
}
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define int unsigned int
#define mod 1000000007
#define double long double
//int d;
int p[200005];
vector <int> adj[200005];  
int val[200005];
vector <int> vis(200005);
//vector <vector <int>> v(200005);

/*int fun(int a,int b){
    if(b==0)return 1;
    else if(a==1)return 1;
    int temp=fun(a,b/2)%mod;
    temp=(temp*temp)%mod;
     if(b%2==1)temp=(temp*a)%mod;
    return temp%mod;
}
 
int inv(int a,int b){
    return (a*fun(b,mod-2))%mod;
}
void dfs(int s){
    if(vis[s])return;
    val[s]+=val[p[s]];
    vis[s]=1;
    for(auto u:adj[s]){
        dfs(u);
    }
}
*/



 
signed main()
{   /*  
   #ifndef ONLINE_JUDGE 
   freopen("inputhsr.txt", "r", stdin);  
   freopen("outputhsr.txt", "w", stdout); 
   #endif 
   */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int i,j,k=0,n,t=1,m,l=0;
    
    
    
    //cin>>t;
    while(t--){
        cin>>n;
        
       for(i=0;i<=n;i++)vis[i]=0;
       for(i=0;i<=n;i++){
            adj[i].clear();
            val[i]=0;
       }
       vector <pair<int,int>> v;
       for(i=0;i<n-1;i++){
           cin>>l>>m;
           adj[l].push_back(m);
           adj[m].push_back(l);
           v.push_back({l,m});
       }
       //taking 1 ans the root;
       
       int d[n+1]; //d=distance
       
       for(i=0;i<=n;i++){d[i]=100000000000;p[i]=0;}
       queue <int> q;
       
       d[1]=0;     //if 1 is root
       q.push(1);
       vis[1]=1;
       while(!q.empty()){
           int s=q.front();
           q.pop();
           for(auto u:adj[s]){
               if(vis[u])continue;
               vis[u]=1;
               d[u]=d[s]+1;
               p[u]=s;
               q.push(u);
           }
       }
       
       int q1;
       cin>>q1;
       int sum=0;
       for(i=0;i<=n;i++)vis[i]=0;
       while(q1--){
          int x,y,z;
          cin>>x>>y>>z;
          //val[i]+=z;
          sum+=z;
          y--;
          int v1=v[y].first;
          int v2=v[y].second;
          if(x==1){
              //int v1=v[y].first;
              //int v2=v[y].second;
              if(d[v2]>d[v1]){
                  val[v2]-=z;
              }
              else{
                  val[v1]+=z;
                  val[1]-=z;
              }
          }
          else{
              swap(v1,v2);
              if(d[v2]>d[v1]){
                  val[v2]-=z;
              }
              else{
                  val[v1]+=z;
                  val[1]-=z;
              }
              
          }
           
       }
       int ans[n+1];
       for(i=0;i<=n;i++)ans[i]=0;
       q.push(1);
       vis[1]=1;
       while(!q.empty()){
           int s=q.front();
           val[s]+=val[p[s]];
           ans[s]=sum+val[s];
           q.pop();
           for(auto u:adj[s]){
               if(vis[u])continue;
               vis[u]=1;
               //d[u]=d[s]+1;
               //p[u]=s;
               q.push(u);
           }
       }
    
    for(i=1;i<=n;i++){
        cout<<ans[i]<<"\n";
    }
        //memset(a,0,sizeof(a));
        //cout<<fixed<<setprecision(10)<<ans<<"\n";
       
    }
    return 0;
}

