#include <bits/stdc++.h>
#define N 100010
#define INF 0x3f3f3f3f
using namespace std;
int n;
vector<int> edge[N];
pair<int, int> val[N];
int p[N], ans[N];

pair<int, int> getInterval(const pair<int, int> &a, const pair<int, int> &b) {
	return make_pair(max(a.first, b.first), min(a.second, b.second));
}

bool isOdd(int x) {
	return (abs(x) & 1);
}

bool dfs(int u, int fa) {
	if (fa) {
		val[u] = make_pair(val[fa].first - 1, val[fa].second + 1);
	} else {
		val[u] = make_pair(-INF, INF);
	}
	if (~p[u]) {
		pair<int, int> nv = getInterval(make_pair(p[u], p[u]), val[u]);
		if (nv.second < nv.first || isOdd(p[u]) != isOdd(val[u].first)) return false;
		val[u] = nv;
	}
	for (int v: edge[u]) {
		if (v == fa) continue;
		if (!dfs(v, u)) return false;;
		pair<int, int> nv = getInterval(make_pair(val[v].first - 1, val[v].second + 1), val[u]);
		if (nv.second < nv.first || isOdd(val[u].first) == isOdd(val[v].first)) return false;
		val[u] = nv;
	}
	
	for (int v: edge[u]) {
		if (v == fa) continue;
		if (!dfs(v, u)) return false;
		pair<int, int> nv = getInterval(make_pair(val[v].first - 1, val[v].second + 1), val[u]);
		if (nv.second < nv.first || isOdd(val[u].first) == isOdd(val[v].first)) return false;
		val[u] = nv;
	}
	
	ans[u] = val[u].first;
	/*
	cout << u << ' ' << fa << ' ' 
	<< val[fa].first << ' ' << val[fa].second << ' ' 
	<< val[u].first << ' ' << val[u].second << endl;
	*/
	
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	
	int k;
	scanf("%d", &k);
	memset(p, -1, sizeof p);
	
	int root = 1;
	for (int i = 1; i <= k; ++i) {
		int u, pi;
		scanf("%d%d", &u, &pi);
		p[u] = pi;
		root = u;
	}
	
	if (!dfs(root, 0)) puts("No");
	else {
		puts("Yes");
		for (int i = 1; i <= n; ++i) {
			printf("%d\n", ans[i]);
		}
	}
	
}