#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


vector<vector<int> >adj;
int mm[100005];
int mn[100005];
int mx[100005];
bool flag=true;

int dfs(int ver,int pr,int y1,int y2)
{
    set<int>s;
    if(mm[ver]!=-1)
    {
        y1=mm[ver];
        y2=mm[ver];
    }
    for(auto i:adj[ver])
    {
        if(i!=pr)
        {
            int x=dfs(i,ver,y1-1,y2+1);
            mn[ver]=max(mn[ver],mn[i]-1);
            mx[ver]=min(mx[ver],mx[i]+1);
            if(x!=-1)
                s.insert(x^1);
        }
    }

    mn[ver]=max(mn[ver],y1);
    mx[ver]=min(mx[ver],y2);

    if(mm[ver]!=-1)
    {
        if(!(mm[ver]>=mn[ver]&&mm[ver]<=mx[ver]))
        {
            flag=false;
            return 0;
        }
        mx[ver]=mm[ver];
        mn[ver]=mm[ver];        
    }
    if(s.size()>1)
    {
        flag=false;
        return 0;
    }
    if(mm[ver]!=-1)
    {
        if(s.size())
        {
            if(!(mm[ver]>=mn[ver]&&mm[ver]<=mx[ver]))
            {
                flag=false;
                return 0;
            }
            mn[ver]=mm[ver];
            mx[ver]=mm[ver];
            if((mm[ver]&1)!=*s.begin())
            {
                flag=false;
                return 0;
            }
        }
        else
        {
            return (mm[ver]&1);
        }        
    }
    else
    {
        if(s.size())
            return (*s.begin());   
    }    
    return -1;
}

void dfs2(int ver,int pr,int x,int y,int par)
{
    x=max(mn[ver],x);
    y=min(mx[ver],y);
    if(x>y)
    {
        flag=false;
        return ;
    }

    if(mm[ver]==-1)
    {
        if((x&1)==par)
        {
            mm[ver]=x;
        }
        else if(x==y)
        {
            flag=false;
            return ;
        }
        else
        {
            mm[ver]=x+1;
        }        
    }
    else if(mm[ver]>y||mm[ver]<x)
    {
        flag=false;
        return ;
    }
    else if((mm[ver]&1)!=par)
    {
        flag=false;
        return ;
    }
    for(auto i:adj[ver])
    {
        if(i!=pr)
        {
            dfs2(i,ver,mm[ver]-1,mm[ver]+1,(par+1)%2);
        }
    }
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    adj.resize(n+1);
    int x,y;
    fill_n(mm,n+1,-1);
    fill_n(mn,n+1,-(1e10));
    fill_n(mx,n+1,1e10);
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    int k;
    cin>>k;
    int ind=1;
    for(int i=0;i<k;i++)
    {
        cin>>x>>y;
        ind=x;
        mm[x]=y;
    }
    dfs(ind,0,mm[ind],mm[ind]);
    if(!flag)
        cout<<"No";
    else
    {
        dfs2(ind,0,mm[ind],mm[ind],(mm[ind]&1));
        if(!flag)
            cout<<"No";
        else
        {
            cout<<"Yes\n";
            for(int i=1;i<=n;i++)
                cout<<mm[i]<<"\n";
        }
        
    }
    

}



Measured memory_bytes: 24448