//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 4e5 + 100;
const int LOG = 25;
const int mod = 1e9 + 7;
const int MX = 5e5 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

vector<int> g[MAXN];

bool flag = false;
int L[MAXN], R[MAXN];
int used[MAXN];

void dfs_down(int v, int p) {
    for (int to:g[v]) {
        if (to == p)
            continue;
        if (L[to] < L[v] - 1) {
            L[to] = L[v] - 1;
            flag = true;
        }
        if (R[to] > R[v] + 1) {
            R[to] = R[v] + 1;
            flag = true;
        }
        if (used[v]) {
            if (used[to] == used[v]) {
                cout << "No";
                exit(0);
            }
            used[to] = 3 ^ used[v];
        }
        dfs_down(to, v);
    }
}

void dfs_up(int v, int p) {
    for (int to:g[v]) {
        if (to == p)
            continue;

        dfs_up(to, v);

        if (L[v] < L[to] - 1) {
            L[v] = L[to] - 1;
            flag = true;
        }
        if (R[v] > R[to] + 1) {
            R[v] = R[to] + 1;
            flag = true;
        }
        if (used[to]) {
            if (used[to] == used[v]) {
                cout << "No";
                exit(0);
            }
            used[v] = 3 ^ used[to];
        }
    }
}

int val[MAXN];

void dfs(int v, int p) {
    val[v] = L[v];
    dout <<v <<" : "<<val[v]<<" - "<<L[v]<<" "<<R[v]<<" -- "<<used[v]<<endl;
    if(  ( (val[v] + inf_int)%2) != used[v]%2 ){
        val[v]++;
    }
    if(val[v] > R[v]){
        dout <<"Last No"<<endl;
        cout <<"No";
        exit(0);
    }
    for (int to:g[v]) {
        if (to == p)
            continue;
        L[to] = max(L[to], val[v] - 1);
        R[to] = min(R[to], val[v] + 1);
        dfs(to, v);
    }
}

void solve() {
    int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    int k;
    cin >> k;
    for (int i = 1; i <= n; ++i) {
        L[i] = -inf_int;
        R[i] = inf_int;
    }
    for (int i = 1; i <= k; ++i) {
        int v, x;
        cin >> v >> x;
        L[v] = R[v] = x;
        if(x%2==1){
            used[v] = 1;
        } else{
            used[v] = 2;
        }
    }

    int it = 1;
    while (true) {
        dout << "it " << it << endl;
        it++;
        flag = false;
        dfs_up(1, -1);
        dfs_down(1, -1);
        for (int i = 1; i <= n; ++i) {
            if (L[i] > R[i]) {
                cout << "No";
                return;
            }
        }
        if (!flag) {
            break;
        }
    }

    dfs(1, -1);
    cout << "Yes\n";
    for (int i = 1; i <= n; ++i) {
        cout << val[i] << "\n";
    }


}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
    //  freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    dout << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 26240