#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define MOD 1000000007
// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int N;
vector<vector<int>> es;
vector<int> A,B;
vector<int> depth;
vector<ll> dp;

void DepthDFS(int a, int d) {
  depth[a]=d;
  for (int  next : es[a]) {
    if(depth[next]==-1) {
      DepthDFS(next,d+1);
    }
  }
}
void ImosDFS(int a, long now) {
  now += dp[a];
  dp[a] = now;
  for (int  next : es[a]) {
    if(depth[next] > depth[a]) {
      ImosDFS(next,now);
    }
  }
}
int main(void) {
  cin >> N;
  es.resize(N);
  A.resize(N);
  B.resize(N);
  depth.resize(N,-1);
  dp.resize(N,0);

  rep(i,N-1) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    es[A[i]].push_back(B[i]);
    es[B[i]].push_back(A[i]);
  }
  DepthDFS(0,0);

  int Q;
  cin >> Q;
  rep(i,Q) {
    int t,e,x;
    cin >> t >> e >> x;
    e--;

    int va,vb;
    if (t==1) {
      va = A[e];
      vb = B[e];
    } else {
      va = B[e];
      vb = A[e];
    }

    if(depth[va] < depth[vb]) {
      dp[0] += x;
      dp[vb] -= x;
    } else {
      dp[va] += x;
    }
  }
  ImosDFS(0,0);
  rep(i,N) {
    cout << dp[i] << endl;
  }
}
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 2e5;
vector<int> adj[MAXN];
int par[MAXN];
int nbSommets;
int id[MAXN];
bool onPath[MAXN];
int cnt;

int getFurthest(int source) {
  vector<int> dis(nbSommets, -1);
  dis[source] = 0;
  queue<int> q;
  q.push(source);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : adj[u])
      if (dis[v] == -1) {
        dis[v] = dis[u] + 1;
        par[v] = u;
        q.push(v);
      }
  }
  int sol = 0;
  for (int i(0); i < nbSommets; ++i)
    if (dis[i] > dis[sol])
      sol = i;
  return sol;
}

void dfs(int u, int p) {
  id[u] = ++cnt;
  for (auto v : adj[u])
    if (v != p and !onPath[v])
      dfs(v, u);
  for (auto v : adj[u])
    if (v != p and onPath[v])
      dfs(v, u);
  ++cnt;
}

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cin >> nbSommets;
  for (int i = 0; i < nbSommets - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int s = getFurthest(0);
  int t = getFurthest(s);
  while (1) {
    onPath[t] = true;
    if (t == s)
      break;
    t = par[t];
  }
  dfs(s, s);
  for (int i = 0; i < nbSommets; ++i) {
    cout << id[i] << ' ';
  }
  cout << endl;
}
