#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;

ll n, Q;
vector<ll> G[200005];
ll a[200005], b[200005];
ll add[200005], ans[200005];
ll parent[200005];

void predfs(int v, int p)
{
	parent[v] = p;
	for(auto u : G[v]){
		if(u == p) continue;
		predfs(u, v);
	}
}

void dfs(int v, int p, ll s)
{
	s += add[v];
	ans[v] = s;
	for(auto u : G[v]){
		if(u == p) continue;
		dfs(u, v, s);
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	rep(i, 1, n-1){
		cin >> a[i] >> b[i];
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	predfs(1, 0);
	
	cin >> Q;
	
	ll t, e, x;
	ll sum = 0;
	rep(i, 1, Q){
		cin >> t >> e >> x;
		ll u = a[e], v = b[e];
		
		if(t == 1){
			if(parent[v] == u) sum += x, add[v] -= x;
			else add[u] += x;
		}
		else{
			if(parent[v] == u) add[v] += x;
			else sum += x, add[u] -= x;
		}
	}
	
	dfs(1, 0, 0);
	
	rep(i, 1, n) cout << ans[i] + sum << "\n";
	flush(cout);
	
	return 0;
}
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

struct UF {
    vi data;
    void init(int n)
    {
        data.resize(n);
        fill(all(data), -1);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        x = root(x);
        return -data[x];
    }
    bool is_root(int x)
    {
        return x == root(x);
    }
};

UF uf;
vector<int> G[200020];

signed main()
{
    int N, M; cin >> N >> M;
    vi a(N), b(N);
    vector<ll> asum(N), bsum(N);
    uf.init(N + 5);

    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];

    rep(i, M) {
        int c, d; cin >> c >> d;
        --c, --d;
        uf.unite(c, d);
    }

    rep(i, N) {
        asum[uf.root(i)] += a[i];
        bsum[uf.root(i)] += b[i];
    }

    bool f = true;
    rep(i, N) {
        if (asum[i] != bsum[i]) f = false;
    }

    cout << (f ? "Yes" : "No") << '\n';
}
