#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int a[100010], b[100010];
int v[100010], p[100010];
vector<int> g[100010];

bool used[100010];
P memo[100010];
int res[100010];

void calc(int s, int val) {
    res[s] = val;
    for (int i = 0; i < g[s].size(); i++) {
        int idx = g[s][i];
        if (!used[idx]) {
            used[idx] = true;
            if (memo[idx].first <= val-1 && val-1 <= memo[idx].second) calc(idx, val-1);
            else calc(idx, val+1);
        }
    }
}

inline P intersect(P p0, P p1) {
    if (p0.second < p1.first || p1.second < p0.first) return P(inf, -inf);
    return P(max(p0.first, p1.first), min(p0.second, p1.second));
}

P rec(int s, P q) {
    if (memo[s].first >= 0) {
        if ((q.first-memo[s].first)%2 != 0 || !(q.first <= memo[s].first && memo[s].second <= q.second)) return P(inf, -inf);
        q = memo[s];
        for (int i = 0; i < g[s].size(); i++) {
            int idx = g[s][i];
            if (!used[idx]) {
                used[idx] = true;
                P ret = rec(idx, P(q.first-1, q.second+1));
                if (ret.first > ret.second) return ret;
                memo[s] = intersect(memo[s], ret);
                if (memo[s].first > memo[s].second) return memo[s];
            }
        }
        return P(memo[s].first-1, memo[s].second+1);
    } else {
        memo[s] = q;
        for (int i = 0; i < g[s].size(); i++) {
            int idx = g[s][i];
            if (!used[idx]) {
                used[idx] = true;
                P ret = rec(idx, P(q.first-1, q.second+1));
                if (ret.first > ret.second) return ret;
                memo[s] = intersect(memo[s], ret);
                if (memo[s].first > memo[s].second) return memo[s];
            }
        }
        return P(memo[s].first-1, memo[s].second+1);
    }
}

void solve() {
    for (int i = 0; i < n-1; i++) {
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    memset(used, false, sizeof(used));
    fill_n(memo, n, P(-1, -1));

    for (int i = 0; i < k; i++) {
        memo[v[i]] = P(p[i], p[i]);
    }
    used[v[0]] = true;
    P pp = P(p[0], p[0]);
    P pq = rec(v[0], pp);
    if (pq.first > pq.second) {
        cout << "No" << endl;
        return;
    }
    memset(used, false, sizeof(used));
    used[v[0]] = true;
    calc(v[0], p[0]);
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
        cout << res[i] << endl;
    }
}

void input() {
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    cin >> k;
    for (int i = 0; i < k; i++) {
        cin >> v[i] >> p[i];
        v[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}

Measured memory_bytes: 14848