#include <bits/stdc++.h>
int main(void) {
  int n;
  std::vector<int> graph[1 + (2 * 100 * 1000)];
  int color[1 + (2 * 100 * 1000)];
  int component[1 + (2 * 100 * 1000)];
  int n_components;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &color[i]);
    component[i] = -1;
  }
  n_components = 0;
  for (int i = 1; i <= n; i++) {
    if (component[i] == -1) {
      n_components++;
      std::queue<int> q;
      component[i] = i;
      q.push(i);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : graph[u]) {
          if (component[v] == -1 && color[v] == color[i]) {
            component[v] = i;
            q.push(v);
          }
        }
      }
    }
  }
  bool feasible = false;
  for (int i = 1; i <= n; i++) {
    int self_adjacencies = 0;
    for (auto u : graph[i]) {
      if (component[u] == component[i]) {
        self_adjacencies++;
      }
    }
    feasible = ((int)graph[i].size() - self_adjacencies == n_components - 1);
    if (feasible) {
      printf("YES\n%d\n", i);
      break;
    }
  }
  if (!feasible) {
    puts("NO");
  }
  return 0;
}
