#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}
int n;
int k;
vvector<int> edges;
vector<int> val;
vector<pii> range;
int main(){
    cin >> n;
    edges.resize(n+1);
    val.resize(n+1,-INF);
    range.resize(n+1,pii(-INF,-INF));
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    stack<int> st;
    cin >> k;
    rep(i,k){
        int a,b;
        cin >> a >> b;
        val[a] = b;
        st.push(a);
        range[a] = pii(b,b);
    }

    while(st.size()){
        int d = st.top();
        st.pop();
        foreach(i,edges[d]){
            pii ne_range = range[d];
            --ne_range.first;
            ++ne_range.second;
            if(range[i].first==-INF){
                range[i] = ne_range;
                st.push(i);
                continue;
            }

            if((range[i].first^ne_range.first)&1){
                cout << "No" << endl;
                return 0;
            }
            chmax(ne_range.first,range[i].first);
            chmin(ne_range.second,range[i].second);
            if(ne_range.first>ne_range.second){
                cout << "No" << endl;
                return 0;
            }
            if(ne_range!=range[i]){
                range[i] = ne_range;
                st.push(i);
            }
        }
    }

    repa(i,n+1){
        val[i] = -INF;
    }
    repa(i,n+1){
        if(range[i].first==range[i].second){
            val[i] = range[i].first;
            st.push(i);
            break;
        }
    }
    while(st.size()){
        int d = st.top();
        int me = val[d];
        st.pop();
        foreach(i,edges[d]){
            if(val[i]>-INF)continue;
            if(range[i].first<=me+1&&me+1<=range[i].second){
                val[i] = me + 1;
                st.push(i);
                continue;
            }
            if(range[i].first<=me-1&&me-1<=range[i].second){
                val[i] = me - 1;
                st.push(i);
                continue;
            }
        }
    }

    cout << "Yes" << endl;
    repa(i,n+1){
        cout << val[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8440