#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

struct Condition {
    int num;
    int dist;
};

struct Node {
    std::vector<int> neighbor;
    Condition condition;
    int value;
    int rank;
};

const int DIST_IMPOSSIBLE = -1;
const int DIST_NO_CONDITION = -2;

Condition merge(Condition c1, Condition c2) {
    if (c1.dist == DIST_IMPOSSIBLE) {
        return c1;
    } else if (c2.dist == DIST_IMPOSSIBLE) {
        return c2;
    }

    if (c1.dist == DIST_NO_CONDITION) {
        return c2;
    } else if (c2.dist == DIST_NO_CONDITION) {
        return c1;
    }

    Condition ret_cond;

    if ((c1.num + c1.dist + c2.num + c2.dist) % 2 == 1) {
        ret_cond.dist = DIST_IMPOSSIBLE;
        return ret_cond;
    }

    if (c2.num - c2.dist <= c1.num - c1.dist && c1.num + c1.dist <= c2.num + c2.dist) {
        return c1;
    } else if (c1.num - c1.dist <= c2.num - c2.dist && c2.num + c2.dist <= c1.num + c1.dist) {
        return c2;
    }

    if (c1.num <= c2.num) {
        int min = c2.num - c2.dist;
        int max = c1.num + c1.dist;
        if (max < min) {
            ret_cond.dist = DIST_IMPOSSIBLE;
            return ret_cond;
        } else {
            ret_cond.num = (min + max) / 2;
            ret_cond.dist = max - ret_cond.num;
            return ret_cond;
        }
    } else {
        int min = c1.num - c1.dist;
        int max = c2.num + c2.dist;
        if (max < min) {
            ret_cond.dist = DIST_IMPOSSIBLE;
            return ret_cond;
        } else {
            ret_cond.num = (min + max) / 2;
            ret_cond.dist = max - ret_cond.num;
            return ret_cond;
        }
    }
}

const int MAX_N = 100050;

int N, K;
int A[MAX_N], B[MAX_N], V[MAX_N], P[MAX_N];

Node tree[MAX_N];

void dfs_set_rank(int self, int parent) {
    for (int child : tree[self].neighbor) {
        if (child != parent) {
            tree[child].rank = tree[self].rank + 1;
            dfs_set_rank(child, self);
        }
    }
}

int get_one_value(Condition cond) {
    if (cond.dist % 2 == 0) {
        return cond.num;
    } else {
        return cond.num - 1;
    }
}

void dfs_set_value(int self) {
    Condition pc;
    pc.num = tree[self].value;
    pc.dist = 1;
    for (int child : tree[self].neighbor) {
        if (tree[self].rank < tree[child].rank) {
            Condition cc = merge(pc, tree[child].condition);
            tree[child].value = get_one_value(cc);
            dfs_set_value(child);
            /*
            if (tree[child].condition.num - tree[child].condition.dist <= tree[self].value - 1 && tree[self].value - 1 <= tree[child].condition.num + tree[child].condition.dist) {
                tree[child].value = tree[self].value - 1;
                dfs_set_value(child);
            } else {
                tree[child].value = tree[self].value + 1;
                dfs_set_value(child);
            }
            */
        }
    }
}

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i < N; i++) {
        std::cin >> A[i] >> B[i];
    }
    std::cin >> K;
    for (int i = 1; i <= K; i++) {
        std::cin >> V[i] >> P[i];
    }

    for (int i = 1; i <= N; i++) {
        tree[i].condition.dist = DIST_NO_CONDITION;
    }
    
    for (int i = 1; i < N; i++) {
        tree[A[i]].neighbor.push_back(B[i]);
        tree[B[i]].neighbor.push_back(A[i]);
    }

    for (int i = 1; i <= K; i++) {
        tree[V[i]].condition.num = P[i];
        tree[V[i]].condition.dist = 0;
    }

    tree[1].rank = 0;
    dfs_set_rank(1, -1);

    std::vector<std::pair<int, int>> node_and_rank;
    for (int i = 1; i <= N; i++) {
        node_and_rank.push_back(std::pair<int, int>({i, tree[i].rank}));
    }

    std::sort(node_and_rank.begin(), node_and_rank.end(),
        [](const std::pair<int, int>& a, const std::pair<int, int>& b) { return a.second > b.second; }
    );

    for (auto nr : node_and_rank) {
        int i = nr.first;
        for (int child : tree[i].neighbor) {
            if (tree[i].rank < tree[child].rank) {
                Condition cc = tree[child].condition;
                if (0 <= cc.dist) {
                    cc.dist++;
                }
                tree[i].condition = merge(tree[i].condition, cc);
                if (tree[i].condition.dist == DIST_IMPOSSIBLE) {

                    //std::cout << i << " " << child << " " << cc.num << " " << cc.dist << std::endl;

                    std::cout << "No" << std::endl;
                    return 0;
                }
            }
        }
    }

    tree[1].value = get_one_value(tree[1].condition);
    dfs_set_value(1);

    std::cout << "Yes" << std::endl;
    for (int i = 1; i <= N; i++) {
        std::cout << tree[i].value << std::endl;
    }

    
    return 0;
}

Measured memory_bytes: 14580