#include <bits/stdc++.h>
const int MAXN = 100005;
int main() {
  int n, rootv = 0, potv[2] = {0, 0};
  static int e[MAXN][2], c[MAXN];
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; ++i) scanf("%d%d", &e[i][0], &e[i][1]);
  for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
  for (int i = 1; i <= n - 1; ++i) {
    if (c[e[i][0]] != c[e[i][1]]) {
      if (!rootv) {
        if (!potv[0]) {
          potv[0] = e[i][0];
          potv[1] = e[i][1];
        } else {
          if (e[i][0] == potv[0] || e[i][0] == potv[1])
            rootv = e[i][0];
          else if (e[i][1] == potv[0] || e[i][1] == potv[1])
            rootv = e[i][1];
          else {
            printf("NO");
            return 0;
          }
        }
      } else {
        if (rootv != e[i][0] && rootv != e[i][1]) {
          printf("NO");
          return 0;
        }
      }
    }
  }
  printf("YES\n");
  if (rootv)
    printf("%d", rootv);
  else if (potv[0])
    printf("%d", potv[0]);
  else
    printf("1");
  return 0;
}
