#include<bits/stdc++.h>

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp, tmp);
	if(b & 1) tmp = mulMod(tmp, a);
	return tmp;
}

/////////////////////////////////////////////////////////

const int N = 1e5;


int n;
vi G[N + 5];
int root;
int num[N + 5];
pii rang[N + 5];
bool flag;
vi lst;

void input(){
	cin >> n;
	int u,v;
	FOR(i,n-1){
		cin >> u >> v;
		u--; v--;
		G[u].PB(v);
		G[v].PB(u);
	}
	int q, p;
	cin >> q;
	FOR(i,q){
		cin >> v >> p;
		v--;
		num[v] = p;
		root = v;
	}
}

void output(){
	if(!flag) cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		FOR(i,n) cout << num[i] << endl;
	}
}

bool bfs(){
	queue < pair < pii , int > > que;
	que.push(MP(MP(root, -1), num[root]%2));
	while(!que.empty()){
		int u = que.front().FI.FI;
		int p = que.front().FI.SE;
		int bi = que.front().SE;
		que.pop();
		lst.PB(u);
		if(num[u] != -1 && num[u] % 2 != bi) return false;
		for(int v : G[u]){
			if(v == p) continue;
			que.push(MP(MP(v, u), 1 - bi));
		}
	}
	return true;
}

bool vis[N + 5];

void getRange(){
	FORD(i,lst.size()){
		int u = lst[i];
		vis[u] = true;
		if(rang[u].FI > rang[u].SE || (num[u] != -1 && (rang[u].FI > num[u] || rang[u].SE < num[u]))){
			flag = false;
			return;
		}
		if(num[u] != -1){
			rang[u] = MP(num[u], num[u]);
		}
		for(int v : G[u]){
			if(!vis[v]){
				rang[v] = MP(max(rang[v].FI, rang[u].FI-1), min(rang[v].SE, rang[u].SE+1));
			}
		}
	}
}

void bfs2(){
	queue < pair < pii , int > > que;
	que.push(MP(MP(root, -1), num[root]-1));
	while(!que.empty()){
		int u = que.front().FI.FI;
		int p = que.front().FI.SE;
		int val = que.front().SE;
		que.pop();
		if(val + 1 <= rang[u].SE) num[u] = val + 1;
		else num[u] = val - 1;
		for(int v : G[u]){
			if(v == p) continue;
			que.push(MP(MP(v, u), num[u]));
		}
	}
	FOR(i,n){
		if(num[i] > rang[i].SE || num[i] < rang[i].FI){
			flag = false;
			return;
		}
	}
}

void process(){
	if(!bfs()){
		flag = false;
		return;
	}
	rang[root] = MP(num[root], num[root]);
	getRange();
//	FOR(i,n) printf("%d ",lst[i]);
//	puts("");
//	FOR(i,n) printf("%d -> %d %d\n",i,rang[i].FI,rang[i].SE);
	FOR(i,n){
		if(num[i] != -1 && (rang[i].FI > num[i] || rang[i].SE > num[i])){
			flag = false;
			return;
		}
		if(rang[i].FI > rang[i].SE){
			flag = false;
			return;
		}
	}
	bfs2();
}

void reset(){
	memset(num,-1,sizeof num);
	memset(vis,0,sizeof vis);
	FOR(i,N+3) rang[i] = MP(-INF,INF);
	flag = true;
}

int main(){
//	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	reset();
	input();
	process();
	output();
	return 0;
}

Measured memory_bytes: 9336