/*

* AC 78 ms 14208 KB

*/

#include <cstdio>

#include <iostream>

#include <vector>

using namespace std;

#define INF 1e9

int N, K;

vector<int> edge[100005]; // edge[i] connect from i to edge[i][j].

int v[100005]; // v[i] is written in vertex i

int par[100005]; // vertex i's parent is par[i]

int lb[100005], ub[100005]; // Range [lb[i], ub[i]] is allowed at vertex i, v[i] must be in [lb[i], ub[i]]

int root;

void dfs(int vertex) {

for (int i = 0; i < edge[vertex].size(); ++i) {

int nextVertex = edge[vertex][i];

if (nextVertex != par[vertex]) {

par[nextVertex] = vertex;

dfs(nextVertex);

} else {

// skip this

}

}

for (int i = 0; i < edge[vertex].size(); ++i) {

int nextVertex = edge[vertex][i];

lb[vertex] = max(lb[vertex], lb[nextVertex] - 1);

ub[vertex] = min(ub[vertex], ub[nextVertex] + 1);

}

}

// Decide the example of v[i]

void dfs2(int vertex) {

for (int i = 0; i < edge[vertex].size(); ++i) {

int nextVertex = edge[vertex][i];

if (nextVertex != par[vertex]) {

par[nextVertex] = vertex;

int tmp;

tmp = v[vertex] + 1;

if (lb[nextVertex] <= tmp && tmp <= ub[nextVertex]) {

v[nextVertex] = tmp;

} else {

tmp = v[vertex] - 1;

if (lb[nextVertex] <= tmp && tmp <= ub[nextVertex]) {

v[nextVertex] = tmp;

} else {

// Error, impossible

lb[root] = INF;

ub[root] = -INF;

return;

}

}

dfs2(nextVertex);

} else {

// skip this

}

}

}

int main(){

//freopen("e3.in", "r", stdin);

scanf("%d", &N);

int a, b;

for (int i = 0; i < N-1; ++i) {

scanf("%d %d", &a, &b);

edge[a].push_back(b);

edge[b].push_back(a);

}

// init

for (int i = 1; i <= N; ++i) {

v[i] = INF;

lb[i] = -INF;

ub[i] = INF;

}

scanf("%d", &K);

for (int i = 0; i < K; ++i) {

int vertex, p;

scanf("%d %d", &vertex, &p);

v[vertex] = p;

lb[vertex] = ub[vertex] = p;

root = vertex;

}

par[root] = root;

dfs(root);

dfs2(root);

if (lb[root] == v[root] && ub[root] == v[root]) {

// possible

printf("Yes\n");

for (int i = 1; i <=N; ++i) {

printf("%d\n", v[i]);

}

} else {

printf("No\n");

}

return 0;

}