#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
//#define mod 998244353
#define inf 1e18
#define PI 3.14159265
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,n) x.clear();x.resize(n,0)
#define precise(x) fixed<<setprecision(x)
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> pbds;

/**
 *  author: nayakashutosh9
 *	created: [2021-04-11 19:52]
 *	"Compete against yourself"
**/

const int N = 1e5 + 5;
int n;
vi a, g[N];
bool vis[N];
set<int> ans;
void dfs(int node, int par) {
	if (vis[a[node]] == 0) {
		ans.insert(node);
	}
	bool prev = vis[a[node]];
	vis[a[node]] = 1;
	for (int j : g[node]) {
		if (j != par) dfs(j, node);
	}
	vis[a[node]] = prev;
}
void solve() {
	cin >> n;
	clr(a, n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 0; i <= n; i++) g[i].clear();
	for (int i = 1; i < n; i++) {
		int x, y; cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	memset(vis, 0, sizeof(vis));
	ans.clear();
	dfs(1, 0);
	for (int i : ans) cout << i << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	//cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		//cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
	}

	return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    A[i] = a;
    B[i] = b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> C(N, -1);
  C[0] = -2;
  {
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
      auto u = que.front();
      que.pop();
      for (int v : G[u]) {
        if (C[v] != -1) continue;
        C[v] = u;
        que.push(v);
      }
    }
  }
  int Q;
  cin >> Q;
  vector<int64_t> res(N, 0);
  for (int q = 0; q < Q; q++) {
    int t, e;
    int64_t x;
    cin >> t >> e >> x;
    e--;
    if (t == 1) {
      if (A[e] == C[B[e]]) {
        res[0] += x;
        res[B[e]] -= x;
      } else {
        res[A[e]] += x;
      }
    } else {
      if (A[e] == C[B[e]]) {
        res[B[e]] += x;
      } else {
        res[0] += x;
        res[A[e]] -= x;
      }
    }
  }
  {
    queue<int> que;
    que.push(0);
    vector<bool> used(N, false);
    used[0] = true;
    while (!que.empty()) {
      auto u = que.front();
      que.pop();
      for (int v : G[u]) {
        if (used[v]) continue;
        que.push(v);
        used[v] = true;
        res[v] += res[u];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}
