#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<math.h>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rrep(i,l,r) for(int i=l;i<=r;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define unq(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define mod 1000000007
//#define mod 998244353
#define ad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
void readv(vector<ll> &a,ll n){
	rep(i,n){
		ll x;
		cin>>x;
		a.push_back(x);
	}
}
void outv(vector<ll> &a,ll n){
	rep(i,n){
		if(i>0)cout<<" ";
		cout<<a[i];
	}
	cout<<"\n";
}
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
#define FACMAX 200010
ll fac[FACMAX],inv[FACMAX],ivf[FACMAX];
void initfac(){
	fac[0]=ivf[0]=inv[1]=1;
	for(ll i=1;i<FACMAX;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=1;i<FACMAX;i++){
		if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
		ivf[i]=po(fac[i],mod-2);
	}
}
ll P(ll n,ll k){
	if(n<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod;
}
ll C(ll n,ll k){
	if(k<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll H(ll n,ll k){
	return C(n+k-1,k);
}

#define N 110
#define M 100010
ll n,m,a[M],b[M],c[N];
vector<ll> g[N];
ll d[N];
void dfs(ll x,ll dep){
	if(d[x]>=0)return;
	d[x]=dep;
	for(auto y:g[x]){
		dfs(y,dep+1);
	}
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	rep(i,n)cin>>c[i];
	rep(i,m){
		if(c[a[i]]==c[b[i]]){
			g[a[i]].pb(b[i]);
			g[b[i]].pb(a[i]);
		}
	}
	rep(i,n)d[i]=-1;
	rep(i,n){
		dfs(i,0);
	}
	rep(i,m){
		bool ans;
		if(c[a[i]]>c[b[i]])ans=0;
		else if(c[a[i]]<c[b[i]])ans=1;
		else if(d[a[i]]+1==d[b[i]])ans=0;
		else if(d[a[i]]==d[b[i]]+1)ans=1;
		else if(d[a[i]]>d[b[i]])ans=0;
		else ans=1;
		cout<<(ans==0?"->":"<-")<<"\n";
		
	}
}

#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
vl val, depth;
ll n;
vector<vl> adj;
void dfs(ll node, ll parent, ll current)
{
	val[node]+=current;
	current=val[node];
	//cout<<node+1<<' '<<1+parent<<' '<<val[node]<<endl;
	for(auto x: adj[node])
	{
		if(x!=parent)
		{
			dfs(x, node, current);
		}
	}
}
void dfs2(ll node, ll parent, ll cur_depth)
{
	depth[node]=cur_depth;
	for(auto x: adj[node])
	{
		if(x!=parent)
		{
			dfs2(x, node, cur_depth+1);
		}
	}
}
void solve()
{
    cin>>n;
    adj.resize(n);
    depth.resize(n, 0);
    map<ll, pl> mp1;
    val.resize(n, 0);
    forr(i, n-1)
    {
    	ll u, v;
    	cin>>u>>v;
    	--u, --v;
    	mp1[i+1]={u, v};
    	adj[u].pb(v), adj[v].pb(u);
    }
    ll q;
    cin>>q;
    dfs2(0, -1, 0);
    while(q--)
    {
    	ll t, e, x;
    	cin>>t>>e>>x;
    	ll st, en;
    	if(t==1)
    	{
    		st=mp1[e].first;
    		en=mp1[e].second;
    	}
    	else
    	{
    		st=mp1[e].second;
    		en=mp1[e].first;
    	}
    	if(depth[st]>depth[en])
    	{
    		val[st]+=x;
    	}
    	else 
    	{
    		//cout<<st+1<<' '<<en+1<<endl;
    		val[0]+=x;
    		val[en]-=x;
    	}
    }
    dfs(0, -1, 0);
    forr(i, n)
    {
    	cout<<val[i]<<endl;
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    // cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}