#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int color[100005];
vector<int> edge[100005];
int parent[100005];
bool dfs(int root, int now) {
  if (color[now] != color[root]) return false;
  for (auto& c : edge[now]) {
    if (c == parent[now]) continue;
    parent[c] = now;
    if (!dfs(root, c)) return false;
  }
  return true;
}
bool check(int root) {
  for (auto& c : edge[root]) {
    parent[c] = root;
    if (!dfs(c, c)) return false;
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &color[i]);
  for (int i = 1; i <= n; i++) {
    for (auto& c : edge[i]) {
      if (color[i] == color[c]) continue;
      if (check(i))
        printf("YES\n%d\n", i);
      else if (check(c))
        printf("YES\n%d\n", c);
      else
        printf("NO\n");
      return 0;
    }
  }
  printf("YES\n1\n");
  return 0;
}
