#include <bits/stdc++.h>
using namespace std;
const int MAX = 100 * 1000 + 10;
int id[MAX], W[MAX], name[MAX], vis[MAX];
int color[MAX], n;
vector<int> G[MAX];
int get(int a) { return id[a] = (a == id[a]) ? a : get(id[a]); }
void join(int a, int b) {
  a = get(a), b = get(b);
  if (a == b) return;
  if (W[a] < W[b]) swap(a, b);
  W[a] += W[b];
  id[b] = a;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n - 1); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = (1); i <= (n); i++) scanf("%d", color + i);
  for (int u = (1); u <= (n); u++) id[u] = u, W[u] = 1;
  for (int u = (1); u <= (n); u++)
    for (int v : G[u])
      if (color[u] == color[v]) join(u, v);
  int cnt = 0;
  for (int u = (1); u <= (n); u++)
    if (get(u) == u) name[u] = cnt++;
  for (int u = (1); u <= (n); u++) {
    int ctr = 0;
    for (int v : G[u]) {
      if (!vis[get(v)]) ctr++;
      vis[get(v)] = 1;
    }
    if (ctr == cnt) {
      printf("YES\n%d\n", u);
      return 0;
    }
    if (ctr == cnt - 1 && !vis[get(u)]) {
      printf("YES\n%d\n", u);
      return 0;
    }
    for (int v : G[u]) {
      vis[get(v)] = 0;
    }
  }
  puts("NO");
  return 0;
}
