#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int M = 2000100;
const long long mod = 1e9 + 7;
int head[N], cnt, c[N], n;
struct Node {
  int to, nex;
} edge[N * 2];
void add(int p, int q) {
  edge[cnt].to = q, edge[cnt].nex = head[p], head[p] = cnt++;
}
int rt, flag;
void dfs1(int p, int ft) {
  if (flag) return;
  for (int i = head[p]; ~i; i = edge[i].nex) {
    int q = edge[i].to;
    if (q != ft) {
      dfs1(q, p);
      if (c[p] != c[q] && !flag) {
        rt = p;
        flag = true;
        return;
      }
    }
  }
}
bool vis[N], ok;
void dfs2(int p, int ft) {
  for (int i = head[p]; ~i; i = edge[i].nex) {
    int q = edge[i].to;
    if (q != ft) {
      dfs2(q, p);
      if (p != rt && (c[p] != c[q] || vis[q]))
        vis[p] = true;
      else if (p == rt)
        if (vis[q]) ok = true;
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b), add(b, a);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  dfs1(1, -1);
  if (!rt)
    printf("YES\n1\n");
  else {
    dfs2(rt, -1);
    if (ok)
      printf("NO\n");
    else
      printf("YES\n%d\n", rt);
  }
  return 0;
}
