#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9;
vector <vector <int> > edge;
vector <int> l, r;
inline void print (string message) {
    cout << message << '\n';
    for (int i = 0; i < (int)l.size(); i++) {
        cout << l[i] << ' ' << r[i] << '\n';
    }
    cout << '\n';
}
inline void dfs (int v, int p = -1, int pr_l = -INF, int pr_r = INF) {
    if (l[v] >= 0 && pr_l >= 0 && ((l[v] % 2) != (pr_l % 2))) {
//        cout << v << '\n';
//        print("No1");
        cout << "No\n";
        exit(0);
    }
    l[v] = max(l[v], pr_l);
    r[v] = min(r[v], pr_r);
    for (auto &i : edge[v]) {
        if (i != p) {
            dfs(i, v, l[v] - 1, r[v] + 1);
            if (l[v] < 0) {
                l[v] = l[i] - 1;
                r[v] = r[i] + 1;
            }
            else if ((l[v] % 2) != (l[i] % 2) || l[i] < 0) {
                l[v] = max(l[v], l[i] - 1);
                r[v] = min(r[v], r[i] + 1);
            }
            else {
                cout << "No\n";
                exit(0);
            }
        }
    }
    if (r[v] < l[v]) {
        cout << "No\n";
        exit(0);
    }
}
inline void dfs1 (int v, int p = -1, int pr_l = -INF, int pr_r = INF) {
    if (l[v] >= 0 && pr_l >= 0 && (l[v] % 2 != pr_l % 2)) {
        cout << "No\n";
        exit(0);
    }
    l[v] = max(l[v], pr_l);
    r[v] = min(r[v], pr_r);
    for (auto &i : edge[v]) {
        if (i != p) {
            dfs1(i, v, l[v] - 1, r[v] + 1);
        }
    }
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    edge.resize(n);
    int u, v, add = n + 100;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        --u, --v;
        edge[v].pb(u);
        edge[u].pb(v);
    }
    int m;
    cin >> m;
    l.assign(n, -INF);
    r.assign(n, INF);
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        v += add;
        --u;
        l[u] = r[u] = v;
    }
    dfs(0);
//    print("check\n\n");
    dfs1(0);
    cout << "Yes\n";
    for (int i = 0; i < n; i++) {
        cout << l[i] - add << '\n';
    }
}


Measured memory_bytes: 11904