//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


//#define int long long

using namespace std;

signed compare_ll(const void *a, const void *b)
{
	ll *A = (ll *)a;
	ll *B = (ll *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


struct pret_t{
	int min;
	int max;
	int bl;
};

pret_t search(int x,vvi& graph,vi& come,vi& num,vector<pret_t>& pretvec){
	int i;
	pret_t pret;
	pret_t ptemp;

	come[x]=1;

	if(num[x]==-1){
		pret.min=0;
		pret.max=0;
		pret.bl=0;
	}else{
		pret.min=num[x];
		pret.max=num[x];
		pret.bl=1;
	}

	for(i=0;i<graph[x].size();i++){
		if(come[graph[x][i]]!=0) continue;
		ptemp=search(graph[x][i],graph,come,num,pretvec);
		if(ptemp.bl==0) continue;
		if(ptemp.bl==2){
			pret.bl=2;
			break;
		}
		ptemp.max++;
		ptemp.min--;
		if(pret.bl==0){
			pret=ptemp;
			pret.bl=1;
		}else{
			if((pret.max-ptemp.max)%2!=0){
				pret.bl=2;
				break;
			}
			pret.max=min(pret.max,ptemp.max);
			pret.min=max(pret.min,ptemp.min);
			if(pret.max<pret.min){
				pret.bl=2;
				break;
			}
		}
	}

	pretvec[x]=pret;
	return pret;
}

int inverse(int x,int prev,vvi& graph,vi& come,vi& num,vector<pret_t>& pretvec){
	int i;
	pret_t pret;
	pret_t ptemp;

	come[x]=1;

	if(pretvec[x].min<=prev+1&&prev+1<=pretvec[x].max){
		num[x]=prev+1;
	}else{
		num[x]=prev-1;
	}

	for(i=0;i<graph[x].size();i++){
		if(come[graph[x][i]]!=0) continue;
		inverse(graph[x][i],num[x],graph,come,num,pretvec);
	}

	return 0;
}

signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	int x,y;
	static int a[100010];
	static int b[100010];
	static int v[100010];
	static int p[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	vector<int> vtemp;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	vvi graph;
	
	//データの読み込み


	scanf("%d",&n);
	//scanf_s("%d",&n);


	//scanf("%s",&s);
	//scanf_s("%s",&s,20);


	for(i=0;i<n-1;i++){
		scanf("%d %d",&a[i],&b[i]);
		//scanf_s("%d %d",&a[i],&b[i]);
	}

	scanf("%d",&m);
	//scanf_s("%d",&m);

	for(i=0;i<m;i++){
		scanf("%d %d",&v[i],&p[i]);
		//scanf_s("%d %d",&v[i],&p[i]);
	}


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	vi vans(n+1,0);
	vi come(n+1,0);
	vi num(n+1,-1);
	vector<pret_t> pretvec(n+1);

	for(i=0;i<=n;i++){
		graph.push_back(vtemp);
	}

	for(i=0;i<n-1;i++){
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}



	for(i=0;i<m;i++){
		num[v[i]]=p[i];
	}

	search(1,graph,come,num,pretvec);
	/*for(i=1;i<=n;i++){
		printf("%d: min=%d max=%d bl=%d\n",i,pretvec[i].min,pretvec[i].max,pretvec[i].bl);
	}*/

	if(pretvec[1].bl==2){
		printf("No");
		return 0;
	}else{
		printf("Yes\n");
	}

	fill(num.begin(),num.end(),0);
	fill(come.begin(),come.end(),0);

	temp=pretvec[1].max-1;
	inverse(1,temp,graph,come,num,pretvec);

	for(i=1;i<=n;i++){
		printf("%d\n",num[i]);
	}

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 24176