#pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// #include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vii = V<int>;
using vvll = V<vll>;
using vvii = V< V<int> >;
using PII = P<int, int>;
using PLL = P<ll, ll>;
#define RevREP(i,n,a) for(ll i=n;i>a;i--)  // (a,n]
#define REP(i,a,n) for(ll i=a;i<n;i++)  // [a,n)
#define rep(i, n) REP(i,0,n)
#define ALL(v) v.begin(),v.end()
#define eb emplace_back
#define pb push_back
#define sz(v) int(v.size())

template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
template< class A, class B > ostream& operator <<(ostream& out, const P<A, B> &p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template< class A > ostream& operator <<(ostream& out, const V<A> &v) {
    out << '[';
    for (int i=0;i<int(v.size());i++) {
        if (i) out << ", ";
        out << v[i];
    }
    return out << ']';
}

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vii c(n);
    rep(i, n) cin >> c[i];
    vvii edges(n);
    rep(i, n - 1) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].eb(b), edges[b].eb(a);
    }

    vii exist(100001, 0), fc(100001, -1);
    vii ans;
    auto rec = [&](auto && me, int i, int p) -> void {
        if (!exist[c[i]]) {
            ans.eb(i + 1);
            exist[c[i]] = 1;
            fc[c[i]] = i;
        }
        for (auto e: edges[i]) {
            if (e == p) continue;
            me(me, e, i);
        }

        if (fc[c[i]] == i) {
            fc[c[i]] = -1;
            exist[c[i]] = 0;
        }
    };
    rec(rec, 0, -1);
    sort(ALL(ans));
    for (auto a: ans) cout << a << '\n';
    return 0;
}

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
vector<pair<int, int>> E[200001];
int A[200001], B[200001];
ll zentai = 0;
ll kari = 0;
ll q[200001];
ll kotae[200001];

void dfs(int a, int mae) {

	kotae[a] = kari;
	for (auto p : E[a]) {
		int to = p.first;
		int e = p.second;
		if (mae == to) continue;

		if (B[e] == a) {
			kari += q[e];
			dfs(to, a);
			kari -= q[e];
		}
		else {
			zentai += q[e];
			kari -= q[e];
			dfs(to, a);
			kari += q[e];
		}

	}

}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> N;
	rep1(i, N - 1) {
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		E[a].pb(mp(b, i));
		E[b].pb(mp(a, i));
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		int t, e, x;
		cin >> t >> e >> x;
		if (t == 2) {
			zentai += x;
			q[e] += -x;
		}
		else q[e] += x;
	}

	dfs(1, 0);

	rep1(i, N) {
		co(zentai + kotae[i]);
	}

	Would you please return 0;
}