#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long N, K;
  const long long MEM = 114;
  long long A[MEM], B[MEM];
  long long V[MEM], P[MEM];
  cin >> N;
  for (long long i = 0; i < (N - 1); ++i) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  cin >> K;
  for (long long i = 0; i < (K); ++i) {
    cin >> V[i] >> P[i];
    V[i]--;
  }
  long long m[MEM], M[MEM];
  long long d[MEM] = {};
  for (long long i = 0; i < (N); ++i) {
    m[i] = -1145141919810893364;
    M[i] = 1145141919810893364;
  }
  for (long long i = 0; i < (K); ++i) {
    m[V[i]] = P[i];
    M[V[i]] = P[i];
    d[V[i]] = 2 - (P[i] % 2);
  }
  vector<long long> G[MEM];
  for (long long i = 0; i < (N - 1); ++i) {
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }
  for (long long k = 0; k < (2); ++k) {
    vector<long long> P;
    bool visited[MEM] = {};
    long long parent[MEM] = {};
    parent[V[0]] = N + 3;
    d[V[0]] = 0;
    P.push_back(V[0]);
    while (P.size() > 0) {
      long long p = P[P.size() - 1];
      if (visited[p] == false) {
        for (long long i = 0; i < (G[p].size()); ++i) {
          parent[G[p][i]] = p;
          if (visited[G[p][i]] == false && parent[p] != G[p][i]) {
            P.push_back(G[p][i]);
            if (d[G[p][i]] == 0) {
              d[G[p][i]] = 3 - d[p];
            }
            m[G[p][i]] = max(m[G[p][i]], m[p] - 1);
            M[G[p][i]] = min(M[G[p][i]], M[p] + 1);
          }
        }
        visited[p] = true;
      } else {
        P.pop_back();
        m[parent[p]] = max(m[parent[p]], m[p] - 1);
        M[parent[p]] = min(M[parent[p]], M[p] + 1);
      }
    }
  }
  for (long long i = 0; i < (N); ++i) {
    if (m[i] > M[i]) do {
        cout << "No" << endl;
        return 0;
      } while (false);
    if ((m[i] + M[i]) % 2 == 1) do {
        cout << "No" << endl;
        return 0;
      } while (false);
  }
  for (long long i = 0; i < (N - 1); ++i) {
    if ((d[A[i]] + d[B[i]]) % 2 == 0) do {
        cout << "No" << endl;
        return 0;
      } while (false);
  }
  cout << "Yes" << endl;
  for (long long i = 0; i < (N); ++i) {
    cout << m[i] << endl;
  }
  return 0;
}
