#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<pll> data(N);
  vector<vector<ll>> connection(N);
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    a -= 1, b -= 1;
    connection.at(a).push_back(b);
    connection.at(b).push_back(a);
    data.at(i) = {a, b};
  }
  queue<pll> q;//now, par
  vector<ll> par(N, -1);
  q.push({0, -1});
  while (!q.empty()) {
    ll now = q.front().first, p = q.front().second;
    q.pop();
    for (ll i = 0; i < connection.at(now).size(); ++i) {
      ll next = connection.at(now).at(i);
      if (next == p) {
        continue;
      }
      par.at(next) = now;
      q.push({next, now});
    }
  }
  vector<ll> ans(N, 0);
  ll Q;
  cin >> Q;
  ll sum = 0;
  for (ll i = 0; i < Q; ++i) {
    ll t, e, x;
    cin >> t >> e >> x;
    e -= 1;
    ll a = data.at(e).first, b = data.at(e).second;
    if (t == 2) {
      swap(a, b);
    }
    if (par.at(a) == b) {
      ans.at(a) += x;
    }
    else {
      ans.at(b) -= x;
      sum += x;
    }
  }
  q.push({0, -1});
  while (!q.empty()) {
    ll now = q.front().first, p = q.front().second;
    q.pop();
    for (ll i = 0; i < connection.at(now).size(); ++i) {
      ll next = connection.at(now).at(i);
      if (next == p) {
        continue;
      }
      ans.at(next) += ans.at(now);
      q.push({next, now});
    }
  }
  for (ll i = 0; i < N; ++i) {
    cout << ans.at(i) + sum << "\n";
  }
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
struct Node;
vector<Node> V;
struct Node {
  vector<int> nbr;
  int d;
  lint ans = 0;
  lint tmp = 0;
  bool vst = false;
  void dfsd(int _d) {
    d = _d;
    vst = true;
    for(int x : nbr) if(!V[x].vst) V[x].dfsd(_d+1);
  }
  void dfs(lint val) {
    ans = val + tmp;
    vst = true;
    for(int x : nbr) if(!V[x].vst) V[x].dfs(ans);
  };
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<int> a(N-1), b(N-1);
  V = vector<Node>(N);
  REP(i, N-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    V[a[i]].nbr.push_back(b[i]);
    V[b[i]].nbr.push_back(a[i]);
  }
  V[0].dfsd(0);
  int Q;
  cin >> Q;
  lint all = 0;
  REP(q, Q) {
    lint t, e, x;
    cin >> t >> e >> x;
    e--;
    if(t == 1) {
      if(V[a[e]].d < V[b[e]].d) {
        V[b[e]].tmp -= x;
        all += x;
      } else {
        V[a[e]].tmp += x;
      }
    } else {
      if(V[a[e]].d > V[b[e]].d) {
        V[a[e]].tmp -= x;
        all += x;
      } else {
        V[b[e]].tmp += x;
      }
    }
  }
  REP(i, N) V[i].vst = false;
  V[0].dfs(0);
  REP(i, N) cout << V[i].ans + all << "\n";
}