#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

struct CWW {
    int l, r, parity;
    CWW() : l(-inf), r(inf), parity(-1) {}
    CWW(int _l, int _r, int _parity) : l(_l), r(_r), parity(_parity) {}
    void print() {
        cout << l << " " << r << " " << parity << endl;
    }
};

const CWW dameCWW = CWW(inf, -inf, -1);

vector<CWW> cww;
Graph G;
vector<int> ans;

bool dame(const CWW& c) {
    return c.l > c.r;
}

CWW merge(const CWW& c1, const CWW& c2) {
    if (dame(c1) || dame(c2)) return dameCWW;
    if (c1.parity == -1 && c2.parity != -1) {
        return c2;
    }
    if (c1.parity != -1 && c2.parity == -1) {
        return c1;
    }
    if (c1.parity == -1 && c2.parity == -1) {
        return CWW();
    }
    if (c1.parity != c2.parity) return dameCWW;
    CWW tmp = CWW(max(c1.l, c2.l), min(c1.r, c2.r), c1.parity);
    if (dame(tmp)) return dameCWW;
    return tmp;
}

CWW expand(const CWW& c) {
    if (c.parity == -1) return c;
    return CWW(c.l - 1, c.r + 1, c.parity^1);
}

CWW dfs(int now, int pre, CWW preCWW) {
    CWW hereCWW = merge(cww[now], preCWW);
    CWW childCWW;
    for (auto nxt : G[now]) {
        if (nxt == pre) continue;
        childCWW = merge(childCWW, dfs(nxt, now, expand(hereCWW)));
    }

    cww[now] = merge(hereCWW, childCWW);
    return expand(cww[now]);
}

void dfs2(int now, int pre, int pre_x) {
    int x;
    if (pre == -1) {
        x = cww[now].l;
    } else {
        if (cww[now].l <= pre_x + 1 && pre_x + 1 <= cww[now].r) {
            x = pre_x + 1;
        } else if (cww[now].l <= pre_x - 1 && pre_x - 1 <= cww[now].r) {
            x = pre_x - 1;
        } else {
            assert(false);
        }
    }
    ans[now] = x;
    for (auto nxt : G[now]) {
        if (nxt == pre) continue;
        dfs2(nxt, now, x);
    }

}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    cin >> n;
    G.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int k;
    cin >> k;
    cww.resize(n);
    rep(i, k) {
        int v, x;
        cin >> v >> x;
        v--;
        cww[v] = CWW(x, x, x % 2);
    }

    dfs(0, -1, CWW());
    CWW ret = dfs(0, -1, CWW());
    if (dame(ret)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        ans.resize(n);
        dfs2(0, -1, -1);
        rep(i, n) {
            cout << ans[i] << endl;
        }
    }

    // rep(i, n) {
    //     cww[i].print();
    // }

}


Measured memory_bytes: 36096