#include <iostream>
#include <bits/stdc++.h>

using namespace std;

void printout(set<int>* g, long* values, long curval, int cn, long* res)
{
    curval+=values[cn];
    res[cn] = curval;
    for (set<int>::iterator it = g[cn].begin();it!=g[cn].end();++it){
        if (res[*it]==-1) printout(g,values,curval,*it,res);
    }
    return;
}


void emain()
{
    int n; cin >> n;
    pair<int,int> ei[n];
    set<int> g[n+1];
    int parent[n+1];
    for (int i=1;i<n;i++) {
        cin >> ei[i].first >> ei[i].second;
        g[ei[i].first].insert(ei[i].second);
        g[ei[i].second].insert(ei[i].first);
        parent[i+1] = 0;
    }
    parent[1] = -1;
    vector<int> toprocess = {1};
    int going;
    while (toprocess.size()){
        going = toprocess.back();
        toprocess.pop_back();
        for (set<int>::iterator it = g[going].begin(); it!=g[going].end();++it){
            if (parent[*it]==0){
                toprocess.push_back(*it);
                parent[*it]=going;
            }
        }
    }
//    for (int i=1;i<=n;i++) cout << parent[i] << " ";
//    cout << endl;
    long values[n+1];
    for (int i=0;i<=n;i++) values[i]=0;
    int q; cin >> q;
    long total = 0;
    int ti,exi;
    long xi;
    for (int i=0;i<q;i++){
        cin >> ti >> exi >> xi;
        if (ti==1){
            if (ei[exi].first==parent[ei[exi].second]){
                values[ei[exi].second]-=xi;
                total+=xi;
            }
            else {
                values[ei[exi].first]+=xi;
            }
        }
        else {
            if (ei[exi].first==parent[ei[exi].second]){
                values[ei[exi].second]+=xi;
            }
            else {
                values[ei[exi].first]-=xi;
                total+=xi;
            }
        }
    }
    long res[n+1];
    for (int i=1;i<=n;i++) res[i] = -1;
    printout(g,values,total,1,res);
    for (int i=1;i<=n;i++){
        cout << res[i] << endl;
    }

    return;
}

void dmain()
{
    int n; cin >> n;
    long ai,bi;
    long aoki = 0;
    long takahashi = 0;
    pair<long,long> cities[n];
    for (int i=0;i<n;i++){
        cin >> ai >> bi;
        cities[i] = {2*ai+bi,ai};
        aoki+=ai;
    }
    sort(cities,cities+n,greater<pair<long,long>>());
    int i=0;
    while (aoki>=takahashi){
        aoki-=cities[i].second;
        takahashi+=cities[i].first-cities[i].second;
        i++;
    }
    cout << i << endl;

    return;
}

void cmain()
{
    int n; cin >> n;
    map<vector<char>,long> m;
    vector<char> si;
    string sis;
    char c;
    int j;
    long val;
    for (int i=0;i<n;i++){
        sis.clear();
        cin >> sis;
        si.clear();
        j=0;
        while (j<sis.size()){
            si.push_back(sis[j]);
            j++;
        }
        if (si[0]=='!'){
            si.erase(si.begin());
            val = 1000000;
        }
        else val = 1;
        if (m.count(si)) m[si]+=val;
        else m[si]=val;
    }
    for (map<vector<char>,long>::iterator it=m.begin();it!=m.end();++it){
        if (it->second>1000000 && it->second%1000000){
            si = it->first;
            for (vector<char>::iterator jt = si.begin();jt!=si.end();++jt){
                cout << *jt;
            }
            return;
        }
    }
    cout << "satisfiable" << endl;
    return;
}

void bmain()
{
    int n; cin >> n;
    int x[n];
    int y[n];
    for (int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    long cpt=0;
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            if (abs(y[i]-y[j])<=abs(x[i]-x[j])) cpt++;
        }
    }
    cout << cpt << endl;
    return;
}

void amain()
{
    string a,b; cin >> a >> b;
    int sa=0;
    int sb=0;
    sa=a[0]+a[1]+a[2]-48*3;
    sb = b[0]+b[1]+b[2]-48*3;
    cout << max(sa,sb) << endl;
    return;
}


int main()
{
    emain();
    return 0;
}

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;

vector<ll> d, sum;
void dfs1(const Graph &G, int v, int p, int D) { 
	d[v] = D;
    for (auto nv : G[v]) {
		if (nv == p)continue;
		dfs1(G, nv, v, D+1);
	}
}

void dfs2(const Graph &G, int v, int p){ 
    for (auto nv : G[v]) {
		if (nv == p)continue;
        sum[nv] += sum[v];
		dfs2(G, nv, v);
	}
}

int main() {
    int n, q;
    cin >> n;
    Graph G(n);
    vector<ll> 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]);
    }
    d.resize(n);
    sum.resize(n);
    dfs1(G, 0, -1, 0);
    cin >> q;
    rep(i, q){
        ll t, e, x;
        cin >> t >> e >> x; e--; 
        if(t == 1){
            if(d[a[e]] < d[b[e]]){
                sum[0] += x;
                sum[b[e]] -= x;
            }else{
                sum[a[e]] += x;
            }
        }else{
            if(d[b[e]] < d[a[e]]){
                sum[0] += x;
                sum[a[e]] -= x;
            }else{
                sum[b[e]] += x;
            }
        }
    }
    dfs2(G, 0, -1);
    rep(i, n)cout << sum[i] << endl;
}   