#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <utility>

typedef long long ll;
typedef std::pair<int, int> pii;

#define mp std::make_pair

int n, k, ans[100005];
bool vis[100005];
int head[100005], next[100005 << 1], to[100005 << 1], ed = 0;
int deg[100005];

void AddEdge(int u, int v) {
	next[++ed] = head[u]; head[u] = ed; to[ed] = v;
}

pii dp[100005];

pii DP(int now, int fa, bool odd, int L, int R) {
	if (vis[now]) {
		if (ans[now] < L || ans[now] > R || (ans[now] & 1) != odd) {
			puts("No"); exit(0);
		}
		L = R = ans[now];
	}
	pii tmp;
	for (int i = head[now]; i; i = next[i]) {
		if (to[i] == fa) continue;
		tmp = DP(to[i], now, odd ^ 1, L - 1, R + 1);
		L = std::max(L, tmp.first - 1);
		R = std::min(R, tmp.second + 1);
		if (L > R) {
			puts("No"); exit(0);
		}
	}
	return dp[now] = mp(L, R);
}

void DFS(int now, int fa, int L, int R) {
	dp[now].first = std::max(dp[now].first, L);
	dp[now].second = std::min(dp[now].second, R);
	ans[now] = dp[now].first;
	for (int i = head[now]; i; i = next[i]) {
		if (to[i] == fa) continue;
		DFS(to[i], now, dp[now].first - 1, dp[now].second + 1);
	}
}

int main() {
	scanf("%d", &n);
	for (int u, v, i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v);
		AddEdge(u, v);
		AddEdge(v, u);
		++deg[u]; ++deg[v];
	}
	scanf("%d", &k);
	int v, p;
	for (int i = 1; i <= k; ++i) {
		scanf("%d%d", &v, &p);
		ans[v] = p;
		vis[v] = 1;
	}

	DP(v, 0, p & 1, p, p);
	DFS(v, 0, p, p);

	puts("Yes");
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);

	return 0;
}