#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define cm (1 << 17)
char cn[cm], *ci = cn + cm, ct;

inline char getcha() {
	if (ci - cn == cm) {
		fread(cn, 1, cm, stdin);
		ci = cn;
	}
	return *ci++;
}

inline int getint() {
	int A = 0;
	while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	return A;
}

static struct FastOutput {
	static constexpr int BUF_SIZE = 1 << 20;
	char buf[BUF_SIZE];
	size_t buf_pos = 0;
	static constexpr int TMP_SIZE = 1 << 20;
	char tmp[TMP_SIZE];
	FILE* out = stdout;

	inline void put_char(char c) {
		buf[buf_pos++] = c;
		if (buf_pos == BUF_SIZE) {
			fwrite(buf, 1, buf_pos, out);
			buf_pos = 0;
		}
	}

	~FastOutput() { fwrite(buf, 1, buf_pos, out); }

	inline FastOutput& operator<<(char c) {
		put_char(c);
		return *this;
	}

	inline FastOutput& operator<<(const char* s) {
		while (*s) {
			put_char(*s++);
		}
		return *this;
	}

	inline FastOutput& operator<<(const string& s) {
		for (int i = 0; i < (int)s.size(); i++) {
			put_char(s[i]);
		}
		return *this;
	}

	template <typename T>
	inline char* integer_to_string(T n) {
		// beware of TMP_SIZE
		char* p = tmp + TMP_SIZE - 1;
		if (n == 0) {
			*--p = '0';
		} else {
			bool is_negative = false;
			if (n < 0) {
				is_negative = true;
				n = -n;
			}
			while (n > 0) {
				*--p = (char)('0' + n % 10);
				n /= 10;
			}
			if (is_negative) {
				*--p = '-';
			}
		}
		return p;
	}

	template <typename T>
	inline typename enable_if<is_integral<T>::value, char*>::type stringify(T n) {
		return integer_to_string(n);
	}

#if !defined(_WIN32) || defined(_WIN64)
	inline char* stringify(__int128 n) { return integer_to_string(n); }
#endif

	template <typename T>
	inline typename enable_if<is_floating_point<T>::value, char*>::type stringify(T n) {
		sprintf(tmp, "%.17f", n);
		return tmp;
	}

	template <typename T>
	inline FastOutput& operator<<(const T& n) {
		auto p = stringify(n);
		for (; *p != 0; p++) {
			put_char(*p);
		}
		return *this;
	}
} fast_output;

#define cout fast_output

int main() {
//	cin.tie(0)->sync_with_stdio(0);
	ll n = getint();
	vector<ll> a(n), b(n);
	vector<vector<ll>> g(n);
	for (ll i = 0; i < n - 1; i++) {
		a[i] = getint() - 1;
		b[i] = getint() - 1;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	vector<ll> ans(n), depth(n);
	function<void(ll, ll)> Dfs = [&](ll u, ll d) {
		depth[u] = d;
		for (ll e : g[u]) {
			if (e != d) {
				ans[e] += ans[u];
				Dfs(e, u);
			}
		}
	};
	Dfs(0, 0);
	ll q = getint();
	while (q--) {
		ll t = getint(), e = getint() - 1, x = getint();
		ll u = a[e], v = b[e];
		if (t == 2) swap(u, v);
		if (depth[u] == v) {
			ans[u] += x;
		} else {
			ans[0] += x;
			ans[v] -= x;
		}
	}
	Dfs(0, 0);
	for (ll e : ans) {
		cout << e << '\n';
	}
}

// 4-10-2020
// FUN WITH CODE -> GON
// Don't be frustrated
// codeforces
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define nes ios_base :: sync_with_stdio(0); cin.tie(0); cout<<fixed; cout.precision(20);
#define f4(i,k,n) for(int i=k;i<n;++i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define inf LLONG_MAX
#define dbvi vector<vector<int>>
#define dbvl vector<vector<ll>>
using namespace std;
ll const mo=1e9+7;
ll mod(ll k){
	return (k+mo)%mo;
}
ll addmod(ll a,ll b){
	return mod(mod(a)+mod(b));
}
ll mulmod(ll a,ll b){
	return mod(mod(a)*mod(b));
}
ll submod(ll a,ll b){
	return mod(a%mo-b%mo+mo)%mo;
}
int cntpw(ll n){
	int cnt=0;
	while(n>0){
		++cnt;
		n/=10;
	}
	return cnt;
}
void solve(){
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;++i) cin>>v[i];
	set<int>se;
	int pr=0;
	for(int i=0;i<n;++i){
		if(pr!=v[i]){
			se.insert(v[i]);
			cout<<pr<<"\n";
		}
		else{
			++pr;
			while(se.count(pr)){
				++pr;
			}
			cout<<pr<<"\n";
			//se.insert(pr);
		}
	}
}
int main(){
	nes;
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
