#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, head[500050], pos;
bool ans[500050];
int cnt[500050], oto[500050], c[500050];
struct edge {
  int to, next;
} e[500050];
void add(int a, int b) {
  pos++;
  e[pos].to = b, e[pos].next = head[a], head[a] = pos;
}
void insert(int a, int b) {
  add(a, b);
  add(b, a);
}
bool dfs(int u, int fa) {
  bool k = 1;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    if (c[u] != c[v]) k = 0;
    bool t = dfs(v, u);
    ans[u] &= t;
    if (c[u] != c[v] || (!t)) cnt[u]++, oto[u] = v;
  }
  return (ans[u] & k);
}
bool ret[500050], ok[500050];
void dp(int u, int fa) {
  if (fa && !ret[fa])
    ret[u] = 0;
  else if (fa && (!ok[fa]))
    ret[u] = 0;
  else if (cnt[fa] > 1)
    ret[u] = 0;
  else if (cnt[fa] == 1 && oto[fa] != u)
    ret[u] = 0;
  if (fa) ok[u] = ok[fa];
  if (fa && c[u] != c[fa]) ok[u] = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dp(v, u);
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    insert(x, y);
  }
  for (int i = 1; i <= n; i++) c[i] = read();
  for (int i = 1; i <= n; i++) ans[i] = ok[i] = 1;
  for (int i = 1; i <= n; i++) ret[i] = 1;
  dfs(1, 0);
  dp(1, 0);
  for (int i = 1; i <= n; i++)
    if (ans[i] & ret[i]) {
      printf("YES\n%d", i);
      return 0;
    }
  printf("NO\n");
  return 0;
}
