#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto&
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int n, k;
vector<int> G[100010];
int ma[100010], mi[100010], depth[100010], par[100010];
bool seen[100010];
int ans[100010];

void boo() {
    cout << "No" << endl;
    exit(0);
}

void dfs(int v, int x) {
    for (const int& w : G[v]) {
        if (w == par[v]) continue;
        if (ans[w] != MOD) {
            assert(mi[w] <= ans[w] && ans[w] <= ma[w]);
            dfs(w, ans[w]);
        } else {
            if(mi[w] <= ans[v] + 1 && ans[v] + 1 <= ma[w]) {
                ans[w] = ans[v] + 1;
            } else if(mi[w] <= ans[v] - 1 && ans[v] - 1 <= ma[w]) {
                ans[w] = ans[v] - 1;
            } else {
                boo();
            }
            dfs(w, ans[w]);
        }
    }
}

int main() {
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, n) {
        ma[i] = mi[i] + 1;
        ans[i] = MOD;
    }

    cin >> k;
    vector<int> f(k);
    rep(i, k) {
        cin >> f[i];
        f[i]--;
        int x;
        cin >> x;
        ma[f[i]] = mi[f[i]] = x;
        ans[f[i]] = x;
    }

    depth[f[0]] = 0;
    par[f[0]] = -1;

    typedef pair<int, int> pii;
    priority_queue<pii> pq;
    queue<int> q;
    q.push(f[0]);

    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (const int& w : G[v]) {
            if (w == par[v]) continue;

            par[w] = v;
            depth[w] = depth[v] + 1;

            if (ma[w] == mi[w]) {
                pq.push({depth[w], w});
                seen[w] = true;
            } else {
                ma[w] = ma[v] + 1;
                mi[w] = mi[v] - 1;
            }
            q.push(w);
        }
    }

    while (!pq.empty()) {
        int w = pq.top().second;
        int v = par[w];
        pq.pop();

        // cout << pq.top().first << " " << w << endl;

        if (v == -1) continue;

        if (ma[v] % 2 == ma[w] % 2) boo();
        if (mi[v] % 2 == mi[w] % 2) boo();

        ma[v] = min(ma[v], ma[w] + 1);
        mi[v] = max(mi[v], mi[w] - 1);

        if (ma[v] < mi[v]) boo();
        if (seen[v]) continue;
        seen[v] = true;
        pq.push({depth[v], v});
    }

    rep(i, n) {
        if (ma[i] < mi[i]) boo();
    }

    dfs(f[0], ans[f[0]]);
    cout << "Yes" << endl;
    rep(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 11900