#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int a, vis[N], b, c, d[N], n, m, cn, fin, co[N];
vector<int> E[N];
void dfs(int x, int y, int z) {
  if (d[x] != z) {
    co[x]++;
    return;
  }
  if (vis[x]) return;
  vis[x] = 1;
  for (int i : E[x])
    if (i ^ y) dfs(i, x, z);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) co[i] = 1;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    E[a].push_back(b);
    E[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0, d[i]), cn++;
  for (int i = 1; i <= n; i++) {
    if (co[i] == cn) {
      puts("YES");
      printf("%d\n", i);
      return 0;
    }
  }
  puts("NO");
  return 0;
}
