using namespace std;
#include <iostream>
#include <vector>
#define PB push_back
#define rep(a,b,c) for(int a=b;a<c;a++)
#define Rep(a,b,c) for(int a=b;a<c;a++)
#define rep_(a,b,c) for(c::iterator a=b.begin();a!=b.end();a++)

int l[100005],r[100005],d[100005]={0};
int even[100005]={0};//0 undetermined 1 even 2 odd
vector<int> v[100005];

bool tree1(int t)
{
	rep_(i,v[t],vector<int>)
		if (d[*i]==0)
		{
			d[*i]=d[t]+1;
			if (!tree1(*i)) return false;
			l[t]=max(l[t],l[*i]-1);
			r[t]=min(r[t],r[*i]+1);
			if (even[*i]!=0)
			{
				if (even[*i]==even[t]) return false;
				else even[t]=3-even[*i];
			}
			if (l[t]>r[t]) return false;
		}
	return true;
}

bool tree2(int t)
{
	rep_(i,v[t],vector<int>)
		if (d[*i]==d[t]+1)
			l[*i]=max(l[*i],l[t]-1),tree2(*i);
}

int main()
{
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);
	int n,k,t1,t2;
	cin >> n;
	rep(i,0,n-1)
	{
		cin >> t1>>t2;
		v[t2].PB(t1);
		v[t1].PB(t2);
	}
	rep(i,1,n+1)
	{
		l[i]=-1000005;
		r[i]=2000005;
	}
	cin >> k;
	rep(i,0,k)
	{
		cin>>t1>>t2;
		l[t1]=r[t1]=t2;
		even[t1]=1+t2%2;
	}
	d[1]=1;
	if (!tree1(1)) cout << "No\n";
	else
	{
		tree2(1);
		cout << "Yes\n";
		rep(i,1,n+1) cout << l[i] << endl;
	}
	//rep(i,1,n+1)
	//	cout << l[i] << ' ' << r[i] << ' '<<even[i] << endl;

}

