#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;

vector<ll> d, sum;
void dfs1(const Graph &G, int v, int p, int D) { 
	d[v] = D;
    for (auto nv : G[v]) {
		if (nv == p)continue;
		dfs1(G, nv, v, D+1);
	}
}

void dfs2(const Graph &G, int v, int p){ 
    for (auto nv : G[v]) {
		if (nv == p)continue;
        sum[nv] += sum[v];
		dfs2(G, nv, v);
	}
}

int main() {
    int n, q;
    cin >> n;
    Graph G(n);
    vector<ll> a(n-1), b(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    d.resize(n);
    sum.resize(n);
    dfs1(G, 0, -1, 0);
    cin >> q;
    rep(i, q){
        ll t, e, x;
        cin >> t >> e >> x; e--; 
        if(t == 1){
            if(d[a[e]] < d[b[e]]){
                sum[0] += x;
                sum[b[e]] -= x;
            }else{
                sum[a[e]] += x;
            }
        }else{
            if(d[b[e]] < d[a[e]]){
                sum[0] += x;
                sum[a[e]] -= x;
            }else{
                sum[b[e]] += x;
            }
        }
    }
    dfs2(G, 0, -1);
    rep(i, n)cout << sum[i] << endl;
}   
#include <bits/stdc++.h>
using namespace std;
vector<int> v , T;
void build(int node, int l, int r) {
    if (l == r) {
        T[node] = v[l];
    }
    else {
        int mid = (l + r) / 2;
        build(2 * node, l, mid);
        build(2 * node + 1, mid + 1, r);
        T[node] = T[2 * node] ^ T[2 * node + 1];
    }
}
void update(int node, int start, int end, int pos, int value) {
    if (start == end){
        T[node] = value;
        return;
    }
    int mid = (start + end) / 2;
    if (pos <= mid) {
        update(2 * node, start, mid, pos, value);
    }
    else update(2 * node + 1, mid + 1, end, pos, value);
    T[node] = T[2 * node] ^ T[2 * node + 1];
}

int query(int node, int start, int end, int l, int r){
    if (start > r || end < l) return 0;
    if (start >= l && end <= r) {
        return T[node];
    }
    int mid = (start + end) / 2;
    int ans = query(2 * node, start, mid, l, r);
    int ans2 = query(2 * node + 1, mid + 1, end, l, r);
    return ans ^ ans2; 
}

int main(){
    int n , q;
    cin >> n >> q;
    v = vector<int>(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    T = vector<int>(4 * n);
    build(1, 0, n - 1);
    while (q--) {
        int command;
        cin >> command;
        if (command == 1) {
            int x , y;
            cin >> x >> y;
            --x;
            int ans = query(1, 0, n - 1, x, x);
            update(1, 0, n - 1, x, ans ^ y);
        }
        else if (command == 2) {
            int x, y;
            cin >> x >> y;
            --x; --y;
            int ans = query(1, 0, n - 1, x, y);
            cout << ans << endl;
        }
        else assert(false);
    }
    return 0;
}
