#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
const int N = 200000;

int n;
int ans[N], in[N];
vector <int> a[N];
priority_queue< pair<int,int> > q;

int main(void)
{
	scanf("%d", &n);
	for (int i=1;i<n;++i)
	{
		int x, y; scanf("%d %d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	memset(ans,-1,sizeof ans);
	int m; scanf("%d", &m);
	for (int i=1;i<=m;++i)
	{
		int x, v; scanf("%d %d", &x, &v);
		ans[x] = v; q.push(make_pair(-v,x));
	}
	while (q.size())
	{
		int x = q.top().second;
		int v = -q.top().first;
		q.pop(); in[x] = 1;
		for (int i=0;i<a[x].size();++i)
		{
			int y = a[x][i];
			if (ans[y] >= 0 and !in[y] and (abs(ans[x]-ans[y]) != 1)) {
				puts("No");
				return 0;
			}
			else if (!in[y]) {
				in[y] = 1;
				ans[y] = v + 1;
				q.push(make_pair(-ans[y],y));
			}
		}
	}
	puts("Yes"); 
	for (int i=1;i<=n;++i)
		printf("%d\n", ans[i], i==n?'\n':' ');
	return 0;
} 