#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <assert.h>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define fir for( int i = 1 ; i <= n ; i++ )
#define fjr for( int j = 1 ; j <= n ; j++ )
#define fkr for( int k = 1 ; k <= n ; k++ )
#define firx( _x ) for( int i = 1 ; i <= _x ; i++ )
#define fjrx( _x ) for( int j = 1 ; j <= _x ; j++ )
#define fkrx( _x ) for( int k = 1 ; k <= _x ; k++ )
#define out cout <<
#define ln  << endl
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int

#define ll long long
#define B out "BreakPoint\n";
#define read(_num) scanf("%d",&_num)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_num1,_num2) scanf("%d %d",&_num1,&_num2)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_num1,_num2,_num3) scanf("%d %d %d",&_num1,&_num2,&_num3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
#define MAXN 100100

int n , k;
int val[MAXN];

#define _SHOW_							0
#define _SHOW_PIIPLUS_ 	( _SHOW_ &		1		)
#define _SHOW_MEM_		( _SHOW_ & 		1		)

void no(){
	printf( "No\n" );
	exit( 0 );
}
bool valuable( pii p1 ){
	return p1.F <= p1.S;
}
pii operator+( pii p1 , pii p2 ){	// '+' means ∩(交集)
	pii ret;
	if( !valuable( p1 )  ||  !valuable( p2 ) )
		ret = mp( INF , -INF );
	else{
		if( p1.F > p2.F )
			swap( p1 , p2 );
		if( p1.S < p2.F )
			ret = mp( INF , -INF );
		else
			ret = mp( p2.F , min( p1.S , p2.S ) );
	}
	return ret;
}

vc<int> e[MAXN];
bool vis[MAXN];

//Check the odd/even
void check_jiou( int pos , int fa , int need ){		//need	0:odd	1:even	-1:uknown
	if( val[pos] != -1 ){
		if( ( val[pos] & 1 )  !=  need  &&  need != -1 )
			no();
		else need = ( val[pos] & 1 ) ^ 1;
	}else
		if( need != -1 )
			need ^= 1;
	for( uint i = 0 ; i < e[pos].size() ; i++ )
		if( e[pos][i] != fa )
			check_jiou( e[pos][i] , pos , need );
}

//Check the qujian
pii mem[MAXN];
pii check_qujian( int pos , int fa ){
	pii ret;
	if( val[pos] == -1 ) ret = mp( -INF , INF );
	else ret = mp( val[pos] , val[pos] );

	for( uint i = 0 ; i < e[pos].size() ; i++ )
		if( e[pos][i] != fa ){
			pii sonret = check_qujian( e[pos][i] , pos );
			sonret.F--; sonret.S++;
			ret = ret + sonret;
			if( !valuable( ret ) )
				no();
		}

	mem[pos] = ret;
	return ret;
}

void xout( pii p1 ){
	cout << "( " << p1.F << " , " << p1.S << " )\n";
}

//Print the ans
int ans[MAXN];
void getpath( int pos , int fa , pii now ){
	if( _SHOW_PIIPLUS_ ){
		cout << endl;
		xout( now );
		xout( mem[pos] );
		xout( now+mem[pos] );
		cout << endl;
	}

	now = now + mem[pos];
	ans[pos] = now.F;
	now.F--; now.S++;
	for( uint i = 0 ; i < e[pos].size() ; i++ )
		if( e[pos][i] != fa )
			getpath( e[pos][i] , pos , now );
}

int main(){

	msn( val , -1 );

	read( n );
	firx( n - 1 ){
		int a , b;
		read2( a , b );
		e[a].pb( b );
		e[b].pb( a );
	}

	read( k );
	firx( k ){
		int id , num;
		read2( id , num );
		val[id] = num;
	}

	check_jiou( 1 , -1 , -1);
	check_qujian( 1 , -1 );

	printf( "Yes\n" );

	if( _SHOW_MEM_ )
		for( int i = 1 ; i <= n ; i++ )
			cout << i << " |  " << mem[i].F << " " << mem[i].S << endl;

	getpath( 1 , -1 , mem[1] );

	for( int i = 1 ; i <= n ; i++ )
		printf( "%d\n",ans[i] );

	return 0;
}


Measured memory_bytes: 15744