#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD_CONST = 1000000007ll;


ll modSum(ll a, ll b, ll MOD = MOD_CONST) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


ll modSubtract(ll a, ll b, ll MOD = MOD_CONST) {
  return (((a % MOD) - (b % MOD)) + MOD + MOD) % MOD;
}


ll modProd(ll a, ll b, ll MOD = MOD_CONST) {
  return ((a % MOD) * (b % MOD)) % MOD;
}


ll getPowMod(ll x, ll e, ll MOD = MOD_CONST) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2, MOD);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1, MOD);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


ll getInverse(ll x, ll MOD = MOD_CONST) {
  return getPowMod(x, MOD-2, MOD);
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}


vector<int> getKMP(string &s) {
  int len = (int)s.size();
  vector<int> ret (len, 0);
  for (int i = 1 ; i < len ; i++) {
    int at = ret[i-1];
    while (at > 0 && s[i] != s[at]) {
      at = ret[at-1];
    }
    if (s[i] == s[at]) {
      at++;
    }
    ret[i] = at;
  }
  return ret;
}


string getSubstring(string &s, int from, int to) {
  int l = to-from+1;
  if (l <= 0) {
    return "";
  }
  return s.substr(from, l);
}

ll gcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}


pair<ll, ll> getIntersectingRange(ll a1, ll b1, ll a2, ll b2) {
  ll s = max(a1, a2);
  ll e = min(b1, b2);

  return {s, e};
}


bool isNonEmptyIntersection(ll a1, ll b1, ll a2, ll b2) {
  auto p = getIntersectingRange(a1, b1, a2, b2);
  return p.first <= p.second;
}












const ll INF = 100000000000000ll;
const int MAXN = 100001;


int N, K;
ll val[MAXN];
pair<ll, ll> range[MAXN];
vector<int> G[MAXN];


bool DFS1(int at, int parent = -1) {
  //cerr << "Before visitng children: At = " << at << ", Parent = " << parent << "\n";
  for (int nxt : G[at]) {
    if (nxt == parent) continue;
    if (DFS1(nxt, at) == false) {
      return false;
    }
  }
  //cerr << "Afer visiting children: At = " << at << ", Parent = " << parent << "\n";
  if (range[at].first != -INF) {
    //cerr << "Case finite range\n";
    for (int nxt : G[at]) {
      if (nxt == parent) continue;
      if (range[nxt].first != -INF && (!isNonEmptyIntersection(range[nxt].first-1, range[nxt].second+1, range[at].first, range[at].second))) {
        return false;
      }
    }
  }
  else {
    //cerr << "Case infinite range\n";
    for (int nxt : G[at]) {
      //cerr << "nxt = " << nxt << "\n";
      //cerr << "Cur range = (" << range[at].first << ", " << range[at].second << ")" << "\n";
      //cerr << "Nxt range = (" << range[nxt].first << ", " << range[nxt].second << ")" << "\n";
      if (nxt == parent) {
        continue;
      }
      if (range[nxt].first != -INF) {
        if (range[at].first == -INF) {
          range[at].first = range[nxt].first-1;
          range[at].second = range[nxt].second+1;
        } else {
          if (!isNonEmptyIntersection(range[nxt].first-1, range[nxt].second+1, range[at].first, range[at].second)) {
            //cerr << "Range 1 = (" << range[nxt].first-1 << ", " << range[nxt].second+1 << ")" << "\n";
            //cerr << "Range 2 = (" << range[at].first << ", " << range[at].second << ")" << "\n";
            //cerr << "Returning false\n";
            return false;
          }
          range[at] = getIntersectingRange(range[nxt].first-1, range[nxt].second+1, range[at].first, range[at].second);
        }
      }
    }
  }
  //cerr << "Good before parity check\n";
  //cerr << "Cur Range = " << range[at].first << ", " << range[at].second << "\n\n";
  if (range[at].first != -INF) {
    if (range[at].first > range[at].second) return false;
    if (((range[at].first % 2) + 2) % 2 != ((range[at].second % 2) + 2) % 2) return false;
    //cerr << "Initial okay\n";
    int nxtMod = (((range[at].first + 1) % 2) + 2) % 2;
    for (int nxt : G[at]) {
      if (nxt == parent) continue;
      if (range[nxt].first != -INF) {
        if (((range[nxt].first % 2) + 2) % 2 != nxtMod) {
          return false;
        }
      }
    }
  }
  //cerr << "Returning true with Range = " << range[at].first << ", " << range[at].second << "\n\n";
  return true;
}


void DFS2(int at, int parent = -1) {
  if (range[at].first == -INF) {
    val[at] = 1;
  }
  else {
    val[at] = range[at].first;
  }
  for (int nxt : G[at]) {
    if (nxt == parent) continue;
    range[nxt] = getIntersectingRange(val[at]-1, val[at]+1, range[nxt].first, range[nxt].second);
    DFS2(nxt, at);
  }
}


void input() {
  cin >> N;
  int u, v, p;
  for (int i = 1 ; i <= N-1 ; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1 ; i <= N ; i++) {
    range[i] = {-INF, INF};
    val[i] = -1;
  }
//  cerr << "N = " << N << "\n";
  cin >> K;
//  cerr << "K = " << K << "\n";
  for (int i = 1 ; i <= K ; i++) {
    cin >> v >> p;
    range[v] = {p, p};
  }
//  cerr << "Input over!\n";
}


void preprocess() {
}



bool getAns() {
  bool flag = DFS1(1);
  //cerr << "DFS1 over!\n";
  if (flag) {
    DFS2(1);
    //cerr << "DFS2 over!\n";
  }
  return flag;
}


void solve() {
  if (getAns()) {
    cout << "Yes\n";
    for (int i = 1 ; i <= N ; i++) {
      cout << val[i] << "\n";
    }
  } else {
    cout << "No\n";
  }
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 16512