#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <list>
#include <unordered_set>
//#include <atcoder/convolution>
//#include <atcoder/modint>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
#define bug4(x, y, z, w) cout<<"zdongdebug4: "<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
using namespace std;
//using Modint = atcoder::modint998244353;
typedef long long ll;
void ex_gcd(ll a,ll b, ll& d,ll& x,ll& y){
  if(!b) {d=a;x=1;y=0;}
  else   {	ex_gcd(b,a%b,d,y,x);	y-=a/b*x;}
}
ll inv(ll a,ll n)  {
  ll d,x,y;	ex_gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}
ll gcd(ll x, ll y){
  if(y==0)return x;
  return gcd(y, x%y);
}

const int maxn = 200005;
const int mod = 1000000007;

vector<int>e[maxn];
int d[maxn], pnt[maxn];
int ans[maxn];
bool onit[maxn];

void bfs(int x) {
  memset(d, -1, sizeof(d));
  queue<int>q;
  d[x] = 0;
  pnt[x] = 0;
  q.push(x);
  while(!q.empty()){
    int x = q.front();
    q.pop();
    for(int i=0;i<e[x].size();i++){
      int y = e[x][i];
      if(d[y]!=-1)continue;
      d[y] = d[x] + 1;
      pnt[y] = x;
      q.push(y);
    }
  }
}

int ret;
void dfs(int x,int fa){
  ret++;
  ans[x] = ret;
  int idx = -1;
  for(int i=0;i<e[x].size();i++){
    int y = e[x][i];
    if(y==fa)continue;
    if(onit[y]){
      idx = y;
      continue;
    }
    dfs(y, x);
    ret++;
  }
  if(idx!=-1){
    dfs(idx, x);
    ret++;
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  bfs(1);
  int mx=-1, idx;
  for(int i=1;i<=n;i++){
    if(mx<d[i]){
      mx = d[i];
      idx = i;
    }
  }
  bfs(idx);
  mx = -1;
  for(int i=1;i<=n;i++){
    if(mx<d[i]){
      mx = d[i];
      idx = i;
    }
  }
  int cur = idx;
  while(cur!=0){
    onit[cur] = 1;
    cur = pnt[cur];
  }
  ret = 0;
  dfs(idx, 0);
  for(int i=1;i<n;i++){
    cout<<ans[i]<<" ";
  }
  cout<<ans[n]<<endl;
  return 0;
}
#include<bits/stdc++.h>

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))
#define all(v) v.begin(),v.end()
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 200005;
vector<LL>g[N];
LL n , U[N] , V[N] , q;
LL par[N];
LL ara[N] , add[N];
void dfs(LL node,LL pre)
{
    par[node] = pre;
    for(LL i : g[node]){
        if(i == pre)continue;
        dfs(i,node);
    }
}

void dfs2(LL node,LL pre,LL has){
    has = has + add[node];
    ara[node] = has;
    for(LL i : g[node]){
        if(i == pre)continue;
        dfs2(i,node,has);
    }
}
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n;
    for(LL i = 1;i < n;i++){
        LL u , v;
        cin >> U[i] >> V[i];
        u = U[i];
        v = V[i];
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);

    LL total = 0;
    cin >> q;
    while(q--){
        LL tp , e , x;
        cin >> tp >> e >> x;

        if(tp == 1){
            LL a = U[e];
            LL b = V[e];

            if(par[a] == b){
                add[a] += x;
            }else{
                total += x;
                add[b] -= x;
            }
        }else{
            LL a = V[e];
            LL b = U[e];
            if(par[a] == b){
                add[a] += x;
            }else{
                total += x;
                add[b] -= x;
            }
        }
//        FOR(i,1,n)cout << add[i] << "\n";
//        cout << endl;
    }

    dfs2(1,0,total);
    FOR(i,1,n)cout << ara[i] << "\n";

    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}
