//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
//typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

int N, K;
vector<int>G[100010];
int P[100010];
int L[100010], R[100010];
int ans[100010];
bool possible = true;
void check(int n, int pre, int root,int d) {
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		if (P[nxt] != -1) {
			if (((d+1)%2)!=(abs(P[root]-P[nxt])%2))possible = false;
		}
		check(nxt, n, root, d + 1);
	}
}

void dfs(int n, int pre) {
	int l = L[n], r = R[n];
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		dfs(nxt, n);
		l = max(l, L[nxt]-1);
		r = min(r, R[nxt]+1);
	}
	L[n] = l, R[n] = r;
	if (L[n] > R[n])possible = false;
}

void decide(int n, int pre) {
	//print(n+1);
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		if (ans[n] + 1 >= L[nxt] && ans[n] + 1 <= R[nxt]) {
			ans[nxt] = ans[n] + 1;
		}
		else if (ans[n] - 1 >= L[nxt] && ans[n] - 1 <= R[nxt]) {
			ans[nxt] = ans[n] - 1;
		}
		else {
			//pe(n + 1); print(nxt + 1);
			possible = false;
			return;
		}
		//cout << "->" << ans[n] << endl;
		decide(nxt, n);
	}
}

void solve() {
	cin >> N;
	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v); G[v].push_back(u);
	}
	cin >> K;
	int root = 0;
	REP(i, N)P[i] = -1;

	REP(i, K) {
		int v, p; cin >> v >> p;
		P[v - 1] = p;
		root = v - 1;
	}
	REP(i, N) {
		L[i] = -INF;
		R[i] = INF;
	}
	REP(i, N) {
		if (P[i] != -1) {
			L[i] = P[i];
			R[i] = P[i];
		}
	}
	check(root, root, root, 0);
	
	dfs(root, root);
	if (!possible) { print("No"); return; }
	/*REP(i, N) {
		pe(i + 1); pe(L[i]); print(R[i]);
	}*/
	ans[root] = P[root];
	decide(root, root);
	if (!possible) { print("No"); exit(0); }
	print("Yes");
	REP(i, N)print(ans[i]);
}


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

	solve();
}




Measured memory_bytes: 17408