#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int N, K;
vector<vector<int>>g;
vector<array<int, 2>>bound;
vector<int>ans;

array<int, 2>dfs1(int pos, int lb, int ub, int prevpos) {
	int nextlb, nextub;
	if (bound[pos][0] == -1) {
		nextlb = lb - 1;
		nextub = ub + 1;
	}
	else {
		int fixnum = bound[pos][0];
		if (fixnum < lb || ub < fixnum || (fixnum - lb) % 2 != 0) {
			return{ intmax,intmax };
		}
		lb = fixnum;
		ub = fixnum;
		nextlb = fixnum-1;
		nextub = fixnum+1;
	}

	for (auto x : g[pos])if (x != prevpos) {
		auto re = dfs1(x, nextlb, nextub, pos);
		if (re[0] == intmax)return{ intmax,intmax };
		lb = max(lb, re[0]);
		ub = min(ub, re[1]);
	}
	assert(lb <= ub);
	bound[pos] = { lb,ub };
	return{ lb - 1,ub + 1 };
}

void dfs2(int pos, int lb, int ub, int prevpos) {
	assert((bound[pos][0] <= lb && lb <= bound[pos][1]) || (bound[pos][0] <= ub && ub <= bound[pos][1]));
	if (bound[pos][0] <= lb && lb <= bound[pos][1])ans[pos] = lb;
	else ans[pos] = ub;
	for (auto x : g[pos])if (x != prevpos) {
		dfs2(x, ans[pos] - 1, ans[pos] + 1, pos);
	}
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	g = vector<vector<int>>(N);
	rep(i, N - 1) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		g[A].push_back(B);
		g[B].push_back(A);
	}
	cin >> K;
	bound = vector<array<int,2>>(N);
	rep(i, N)bound[i] = { -1,-1 };
	int root = 0;
	rep(i, K) {
		int V, P;
		cin >> V >> P;
		V--;
		bound[V] = { P,P };
		root = V;
	}

	//木のうち高橋君が整数を書き込んだ頂点のどれかを根にしてdfsする。
	auto re = dfs1(root, bound[root][0], bound[root][1], -1);
	if (re[0] == intmax) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	ans = vector<int>(N, intmax);
	dfs2(root, bound[root][0], bound[root][1], -1);

	rep(i, N) {
		assert(ans[i] != intmax);
		cout << ans[i] << endl;
	}/*

	vector<int>num(N, -123456789);
	stack<array<int,3>>dfs;
	dfs.push({ root,bound[root][0],bound[root][1] });
	while (!dfs.empty()) {
		auto a = dfs.top(); dfs.pop();
		int pos = a[0];
		int lb = a[1] - 1;
		int ub = a[2] + 1;
		if (num[pos] != -123456789)continue;
		num[pos] = lb;
		for (auto x : g[pos]) {
			dfs.push({ x,num[pos]-1,ub });
		}
	}*/


	return 0;
}

Measured memory_bytes: 18176