#include <bits/stdc++.h>
using namespace std;
int n, l[100002], r[100002], g[100002];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) cin >> l[i] >> r[i];
  for (int i = 1; i <= n; i++) cin >> g[i];
  int ar = 0, er = 0;
  for (int i = 1; i < n; i++) {
    if (g[l[i]] != g[r[i]]) {
      if (ar == 0 && er == 0) {
        ar = l[i];
        er = r[i];
        if (ar < er) swap(ar, er);
      } else {
        if (l[i] < r[i]) swap(l[i], r[i]);
        if (ar != l[i] && ar != r[i]) ar = -1;
        if (er != l[i] && er != r[i]) er = -1;
      }
    }
  }
  if (ar < er) swap(ar, er);
  if (ar == -1) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl << (ar == 0 ? 1 : ar) << endl;
  return 0;
}
