#include <bits/stdc++.h>
using namespace std;
inline void scf(int &x) { scanf("%d", &x); }
inline void scf(long long &x) { scanf("%I64d", &x); }
inline void scf(double &x) { scanf("%lf", &x); }
inline void scf(char &x) { scanf("%c", &x); }
inline void scf(char *x) { scanf("%s", x); }
const int N = 2e5 + 7;
const int mars = 0x3c3c3c3c;
typedef int Arr[N];
typedef char Err[N];
int m, n, w, a, b, l, r, q, x, y, cnt;
Arr Lst, Nxt, To, Fa, C, F, T;
void DFS(int u) {
  bool f = 0;
  for (int i = Lst[u]; i; i = Nxt[i]) {
    int v = To[i];
    if (v == Fa[u]) continue;
    Fa[v] = u;
    DFS(v);
    if (F[v] == C[v]) {
      if (F[v] < 0) F[u] = -2;
      if (!F[u]) F[u] = F[v];
      if (F[u] > 0 && F[u] != F[v]) F[u] = -1;
    } else
      F[u] = -2;
  }
  if (!F[u]) F[u] = C[u];
}
void DFS2(int u) {
  if (l) return;
  if (F[u] > -2) {
    l = u;
    return;
  }
  int s = 0, t = 0;
  for (int i = Lst[u]; i; i = Nxt[i]) {
    int v = To[i];
    if (v == Fa[u]) continue;
    if (F[v] != C[u] || F[v] != C[v]) {
      if (t)
        s = 2;
      else
        s = 1, t = v;
    }
  }
  if (T[u]) return;
  if (s == 0) {
    for (int i = Lst[u]; i; i = Nxt[i]) {
      int v = To[i];
      if (v == Fa[u]) continue;
      DFS2(v);
    }
  } else if (s == 1) {
    if (C[t] != C[u]) T[t] = 1;
    DFS2(t);
  }
}
int main() {
  int i, u, v;
  scf(n);
  for (i = 1; i < n; i++) {
    scf(u), scf(v);
    Nxt[i] = Lst[u], Lst[u] = i, To[i] = v;
    Nxt[i + n] = Lst[v], Lst[v] = i + n, To[i + n] = u;
  }
  for (i = 1; i <= n; i++) scf(C[i]);
  DFS(1);
  DFS2(1);
  if (l)
    printf("YES\n%d", l);
  else
    puts("NO");
}
