#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5,M=2*N,inf=1e8;
int n,i,et,he[N],l[N],r[N];bool flag;
struct edge{int l,to;}e[M];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void put(int x){if (x>9) put(x/10);putchar(x%10+48);}
void write(int x){
	if (x<0) putchar('-'),x=-x;
	put(x);putchar('\n');
}
void dfs1(int x,int fa){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].to;if (y==fa) continue;
		dfs1(y,x);
		l[x]=max(l[x],l[y]-1);
		r[x]=min(r[x],r[y]+1);
	}
}
void dfs2(int x,int fa){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].to;if (y==fa) continue;
		l[y]=max(l[y],l[x]-1);
		r[y]=min(r[y],r[x]+1);
		if (!((l[x]^l[y])&1)) flag=0;
		dfs2(y,x);
	}
}
int main(){
	for (n=read(),i=1;i<n;i++){
		int x=read(),y=read();
		e[++et].l=he[x];he[x]=et;e[et].to=y;
		e[++et].l=he[y];he[y]=et;e[et].to=x;
	}
	for (i=1;i<=n;i++) l[i]=-inf,r[i]=inf;
	for (i=read();i--;){
		int x=read();l[x]=r[x]=read();
	}
	dfs1(1,0);flag=1;dfs2(1,0);
	for (i=1;i<=n;i++) if (l[i]>r[i]) flag=0;
	if (!flag){puts("No");return 0;}
	for (puts("Yes"),i=1;i<=n;i++) write(l[i]);
}