#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int k; cin >> k;
  vector<lint> num(n, -1);
  for (int i = 0; i < k; i++) {
    int v, p; cin >> v >> p;
    v--;
    num[v] = p;
  }


  int root = -1;
  for (int i = 0; i < n; i++) {
    if (num[i] != -1) {
      root = i;
      break;
    }
  }

  vector<lint> l(n);
  vector<lint> r(n);

  function<void(int, int, int)> dfs = [&](int cur, int par, int mod2) {

    // 子に対する答えを計算
    int chSize = 0;
    for (auto nxt : g[cur]) {
      if (nxt == par) continue;
      chSize++;
      dfs(nxt, cur, mod2 ^ 1);
    }
    
    // 今が葉なら
    if (chSize == 0) {
      if (num[cur] == -1) {
        l[cur] = -INF;
        r[cur] = INF;
      } else {
        l[cur] = num[cur];
        r[cur] = num[cur];
        if (l[cur] % 2 != r[cur] % 2) {
          l[cur] = INF;
          r[cur] = -INF;
        }
      }
    } else {
      lint L = -INF;
      lint R = INF;
      for (auto nxt : g[cur]) {
        if (nxt == par) continue;
        lint chL = l[nxt];
        lint chR = r[nxt];
        L = max(L, chL - 1);
        R = min(R, chR + 1);
      }
      
      if (num[cur] != -1) {
        L = max(L, num[cur]);
        R = min(R, num[cur]);
      }

      if ((lint)abs(L) % 2 != mod2) {
        L++;
      }

      if ((lint)abs(R) % 2 != mod2) {
        R--;
      }

      if (L > R) {
        L = INF;
        R = -INF;
      }

      l[cur] = L;
      r[cur] = R;
    }
  };

  dfs(root, -1, num[root] % 2);

  if (l[root] == INF) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    vector<lint> ans(n);
    // 根から順番に決定していけばいいかな
    function<void(int, int)> dfs2 = [&](int cur, int par) {
        
      if (par == -1) {
        ans[cur] = num[root];
      } else {
        lint parVal = ans[par];

        if (l[cur] <= parVal - 1 and parVal - 1 <= r[cur]) {
          ans[cur] = parVal - 1;
        } else {
          ans[cur] = parVal + 1;
        }
        assert(l[cur] <= ans[cur] and ans[cur] <= r[cur]);
      }

      for (auto nxt : g[cur]) {
        if (nxt == par) continue;
        dfs2(nxt, cur);
      }
    };

    dfs2(root, -1);

    for (int i = 0; i < n; i++) {
      cout << ans[i] << endl;
    }

  }
  return 0;
}


Measured memory_bytes: 22016