#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, cnt;
int c[maxn], f[maxn], g[maxn], has[maxn], pre[maxn], suf[maxn], ff[maxn];
vector<int> G[maxn];
void dfs1(int u, int fa) {
  ff[u] = fa;
  for (auto v : G[u])
    if (v != fa) dfs1(v, u);
  f[u] = 1;
  for (auto v : G[u])
    if (v != fa && !f[v]) f[u] = 0;
  for (auto v : G[u])
    if (v != fa && c[v] != c[u]) f[u] = 0;
}
void dfs2(int u, int fa) {
  cnt = 0;
  for (auto v : G[u])
    if (v != fa) {
      has[++cnt] = v;
    }
  pre[0] = 1;
  for (int i = 1; i <= cnt; i++)
    pre[i] = pre[i - 1] & f[has[i]] & (c[has[i]] == c[u]);
  suf[cnt + 1] = 1;
  for (int i = cnt; i; i--)
    suf[i] = suf[i + 1] & f[has[i]] & (c[has[i]] == c[u]);
  for (int i = 1; i <= cnt; i++)
    g[has[i]] = g[u] & pre[i - 1] & suf[i + 1] & (c[u] == c[fa]);
  for (auto v : G[u])
    if (v != fa) dfs2(v, u);
}
void Work() {
  dfs1(1, 0);
  g[1] = 1;
  c[0] = c[1];
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) {
    bool ok = g[i];
    for (auto v : G[i])
      if (v != ff[i]) ok &= f[v];
    if (ok) {
      puts("YES");
      printf("%d\n", i);
      return;
    }
  }
  puts("NO");
}
void Init() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
}
int main() {
  Init();
  Work();
  return 0;
}
