#include <bits/stdc++.h>
using namespace std;
const int NIL = -1;
template <class T>
inline T mx(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T mi(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline void sw(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
template <class T>
inline T mabs(T x) {
  return x < 0 ? -x : x;
}
inline char gc() {
  char ret;
  while ((ret = getchar()) == ' ' || ret == '\n' || ret == '\t')
    ;
  return ret;
}
const int LIM = 1e5 + 10;
int u[LIM], v[LIM], c[LIM], ct[LIM];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i < n; i++) cin >> u[i] >> v[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i < n; i++)
    if (c[u[i]] != c[v[i]]) cnt++, ct[u[i]]++, ct[v[i]]++;
  for (int i = 1; i <= n; i++)
    if (cnt == ct[i]) {
      cout << "YES\n" << i;
      return 0;
    }
  cout << "NO";
  return 0;
}
