#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> adj[N];
int n, u[N], v[N], c[N];
int root = -1, color = -1;
bool go(int node, int parent) {
  if (node != root && c[node] != color) {
    return false;
  }
  bool ret = true;
  for (auto child : adj[node]) {
    if (child == parent) continue;
    if (node == root) color = c[child];
    ret &= go(child, node);
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  set<pair<int, int>> edges;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d", u + i, v + i);
    adj[u[i]].push_back(v[i]);
    adj[v[i]].push_back(u[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", c + i);
  }
  for (int i = 0; i < n - 1; ++i) {
    if (c[u[i]] != c[v[i]]) {
      root = u[i];
      if (go(root, -1)) {
        printf("YES\n%d\n", root);
        return 0;
      }
      root = v[i];
      if (go(root, -1)) {
        printf("YES\n%d\n", root);
        return 0;
      }
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n1\n");
  return 0;
}
