#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
 
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
#define ll long long
#define ull unsigned ll
 
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}
 
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}


int dist[100001];
vector<int> G[100001];
vector<int> val[100001];

int main(){
  int n;
  //scanf("%d", &n);
  reader(&n);

  for(int i=0; i<n-1; ++i){
    int a,b;
    //scanf("%d%d", &a,&b);
    reader(&a, &b);
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int k;
  reader(&k);
  //scanf("%d", &k);

  fill(dist, dist+n, 1e8);

  int mn = 1e6, mx=0;
  while(k--){
    int v,p;
    //scanf("%d%d", &v, &p);
    reader(&v, &p);
    v--;

    dist[v] = p;

    mn = min(mn, p);
    mx = max(mx, p);
  }

  if(mx-mn >= n){
    puts("No");
    return 0;
  }

  for(int i=0; i<n; i++){
    if( dist[i] != 1e8 ){
      dist[i] -= mn;
      val[ dist[i] ].push_back( i );
    }
  }

  for(int i=0; i<n; ++i){
    for(int k=0; k<val[i].size(); ++k){
      int p = val[i][k];
      for(int j=0; j<G[p].size(); ++j){
        int nx = G[p][j];
        if( dist[nx] == 1e8 ){
          dist[nx] = i + 1;
          val[i+1].push_back( nx );
        }
        if( abs(dist[p] - dist[nx]) != 1 ){
          puts("No");
          return 0;
        }
      }
    }
  }

  puts("Yes");
  for(int i=0; i<n; ++i){
    //printf("%d\n", dist[i]+mn);
    writerLn(dist[i]+mn);
  }


  return 0;
}


Measured memory_bytes: 11904