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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cerr<<v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
	string bit = "";
	REP(i, len){
	bit += char('0'+(num>>i & 1));
	}
	return bit;
}

const ll INF = (1ll<<60);
vector<ll> lb(101010, -INF), ub(101010, INF), parity(101010, -1);

pll merge(ll L1, ll R1, ll L2, ll R2){
	if(L1 == INF or L2 == INF) return {INF, -INF};
	if(L1 > L2){
		swap(L1, L2);
		swap(R1, R2);
	}

	if(L2>R1){
		return {INF, -INF};
	}else{
		return {L2, min(R1, R2)};
	}
}

void dfs1(ll now, ll par, Graph &G){

	ll L = lb[now], U = ub[now], bi = parity[now];

	for(auto next: G[now]){
		if(next == par) continue;
		dfs1(next, now, G);

		// update of segment
		auto tmp = merge(L, U, lb[next]-1, ub[next]+1);
		L = tmp.first;
		U = tmp.second;

		// update of bi

		if(parity[next] != -1){
			if(bi == -1){
				bi = 1 - parity[next];
			}else{
				if(bi != 1-parity[next]){
					cout << "No" << endl;
					exit(0);
				}
			}
		}
	}

	if(L == INF){
		cout << "No" << endl;
		exit(0);
	}

	lb[now] = L;
	ub[now] = U;
	parity[now] = bi;

	return;
}

void dfs2(ll now, ll par, Graph &G, vector<ll> &P){
	if(par == -1){
		bool tmpari = (lb[now] + INF)%2;
		if(parity[now] == 0 and tmpari == 1) P[now] = lb[now]+1;
		if(parity[now] == 0 and tmpari == 0) P[now] = lb[now];
		if(parity[now] == 1 and tmpari == 1) P[now] = lb[now];
		if(parity[now] == 1 and tmpari == 0) P[now] = lb[now]+1;
	}else{
		ll x1 = P[par]-1;
		ll x2 = P[par]+1;
		if(lb[now]<=x1 and x1<=ub[now]) P[now] = x1;
		else P[now] = x2;
	}

	for(auto next: G[now]){
		if(next == par) continue;
		dfs2(next, now, G, P);
	}
	return;
}

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

	ll N, K;
	cin >> N;

	Graph G(N);
	REP(i, N-1){
		ll u, v;
		cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	cin >> K;
	vector<ll> P(N, -1);
	REP(i, K){
		ll v, p;
		cin >> v >> p;
		v--;
		P[v] = p;
		lb[v] = p;
		ub[v] = p;
		parity[v] = p%2;
	}
	//debug(parity, N);

	dfs1(0, -1, G);

	dfs2(0, -1, G, P);

	cout << "Yes" << endl;
	REP(i, N){
		cout << P[i] << endl;
	}

	//debug(lb, N);
	//debug(ub, N);
	//debug(parity, N);

	return 0;
}

Measured memory_bytes: 18944