#include <bits/stdc++.h>
using namespace std;
int n, r1, r2, t1, t2, f1 = 1, f2 = 1, col[100010];
vector<vector<int>> graph;
bool dfs(const int &v, const int &from, const int &color) {
  if (col[v] != color) return 0;
  for (auto &i : graph[v])
    if (i != from)
      if (!dfs(i, v, color)) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  graph.resize(n + 1);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &r1, &r2);
    graph[r1].push_back(r2);
    graph[r2].push_back(r1);
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &col[i]);
  for (int i = 1; i <= n; ++i)
    for (auto &j : graph[i])
      if (col[i] != col[j]) {
        t1 = i;
        t2 = j;
        break;
      }
  if (!t1) {
    printf("YES\n1");
    return 0;
  }
  for (auto &i : graph[t1]) f1 &= dfs(i, t1, col[i]);
  for (auto &i : graph[t2]) f2 &= dfs(i, t2, col[i]);
  if (f1)
    printf("YES\n%d", t1);
  else if (f2)
    printf("YES\n%d", t2);
  else
    printf("NO");
}
