#include <bits/stdc++.h>
using namespace std;
vector<int> G[(int)1e5 + 7];
int c[(int)1e5 + 7], root, cannot[(int)1e5 + 7];
void dfs(int r, int p) {
  for (int i : G[r]) {
    if (p != i) dfs(i, r);
  }
  for (int i : G[r]) {
    if (cannot[i] && c[r] != c[i]) return;
  }
  cannot[r] = 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++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);
  dfs(1, 0);
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (!cannot[i]) cnt++, root = i;
  if (cnt == 0) {
    puts("YES");
    puts("1");
  } else if (cnt == 1)
    printf("YES\n%d", root);
  else
    puts("NO");
  return 0;
}
