#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

vector<int>E[300000];
ll sum[300000];
int par[300000];
int dep[300000];

void dfs1(int v,int p){
	par[v]=p;
	if(p!=-1)dep[v]=dep[p]+1;
	for(int u:E[v]){
		if(u==p)continue;
		dfs1(u,v);
	}
}
void dfs2(int v,int p){
	if(p!=-1){
		sum[v]+=sum[p];
	}
	for(int u:E[v]){
		if(u==p)continue;
		dfs2(u,v);
	}
}

int A[300000],B[300000];

int main(){
	int n;cin>>n;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
		A[i]=a;B[i]=b;
	}
	dfs1(0,-1);
	int q;cin>>q;
	rep(i,q){
		int t,e,x;scanf("%d%d%d",&t,&e,&x);e--;
		int a=A[e],b=B[e];
		if(dep[a]>dep[b]){
			swap(a,b);
			t=2-t+1;
		}
		if(t==1){
			sum[0]+=x;
			sum[b]-=x;
		}
		else{
			sum[b]+=x;
		}
	}
	dfs2(0,-1);
	rep(i,n){
		printf("%lld\n",sum[i]);
	}
}
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5+69;
int entry[N];
long long scores[N], toAdd[N], tot;
vector<int> tree[N];

void dfs(int c, int p) {
    scores[c] = scores[p] + toAdd[c];
    entry[c] = entry[p] + 1;
    for (int i : tree[c])
        if (i != p)
            dfs(i, c);
}

void query(int x, int y, int z) {
    if (entry[x] > entry[y])
        toAdd[x] += z;
    else {
        tot += z;
        toAdd[y] -= z;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q, x, y, z;
    cin >> n;
    
    int a[n][2];
    for (int i = 1; i < n; ++i) {
        cin >> x >> y;
        a[i][0] = x, a[i][1] = y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    dfs(1, 0);
    cin >> q;
    while (q--) {
        cin >> x >> y >> z;
        if (x == 1)
            query(a[y][0], a[y][1], z);
        else
            query(a[y][1], a[y][0], z);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i)
        cout << scores[i] + tot << '\n';
}