#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

const int VMAX = (int)1e8;

int n;
V< V<int> > edges;
V< P<int, int> > node_range;

bool ok_bar = true;
V<int> col;
void dfs_barp(int i, int p, int c) {
    if (!ok_bar) return;
    col[i] = c;
    for (int e: edges[i]) {
        if (e == p) continue;
        if (col[e] != -1 && (col[e] ^ c) == 0) {
            ok_bar = false;
            return;
        }
        dfs_barp(e, i, c ^ 1);
    }
}

bool ok_range = true;
P<int, int> dfs(int i, int p, P<int, int> par_range) {
    par_range.first--, par_range.second++;
    if (par_range.second < node_range[i].first || par_range.first > node_range[i].second) {
        ok_range = false;
    }
    if (!ok_range) return make_pair(VMAX, -VMAX);
    chmax(node_range[i].first, par_range.first);
    chmin(node_range[i].second, par_range.second);
    for (int e: edges[i]) {
        if (p == e) continue;
        P<int, int> ch_range = dfs(e, i, node_range[i]);
        chmax(node_range[i].first, ch_range.first - 1);
        chmin(node_range[i].second, ch_range.second + 1);
    }
    return node_range[i];
}

V<int> ans;
void dfs_ans(int i, int p, int pval) {
    int candp = pval + 1, candm = pval - 1;
    int cand = INF;
    if (node_range[i].first <= candp && candp <= node_range[i].second) {
        cand = candp;
    } else if (node_range[i].first <= candm && candm <= node_range[i].second) {
        cand = candm;
    }
    ans[i] = cand;
    for (int e: edges[i]) {
        if (e == p) continue;
        dfs_ans(e, i, cand);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    edges.resize(n);
    for (int i = 1; i < n; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].emplace_back(b), edges[b].emplace_back(a);
    }
    node_range.resize(n, make_pair(-VMAX, VMAX) );
    int k; cin >> k;
    int bv = -1;
    col.resize(n, -1);
    for (int i = 0; i < k; i++) {
        int v, p; cin >> v >> p;
        v--;
        node_range[v] = make_pair(p, p);
        if (p & 1) col[v] = 0;
        else col[v] = 1;
        if (bv == -1) bv = v;
    }
    dfs_barp(bv, -1, col[bv]);
    if (!ok_bar) {
        cout << "No\n";
        return 0;
    }
    dfs(bv, -1, make_pair(-VMAX, VMAX));
    if (!ok_range) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    ans.resize(n, VMAX);
    dfs_ans(bv, -1, node_range[bv].second + 1);
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 16304