#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> edges[MAXN];
int c[MAXN];
int rep[MAXN];
bool test(int u, int p, int cur) {
  if (cur != -1 && c[u] != cur) return false;
  bool ans = true;
  for (int v : edges[u])
    if (v != p) {
      if (cur == -1)
        ans &= test(v, u, c[v]);
      else
        ans &= test(v, u, cur);
      if (!ans) break;
    }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", c + i);
    shuffle(edges[i].begin(), edges[i].end(), rng);
  }
  int ans = 0;
  if (test(1, -1, -1)) ans = 1;
  for (int i = 2; !ans && i <= n; i++) {
    for (int j : edges[i]) {
      if (c[i] != c[j]) {
        if (test(i, -1, -1))
          ans = i;
        else if (test(j, -1, -1))
          ans = j;
        if (ans)
          printf("YES\n%d\n", ans);
        else
          printf("NO\n");
        return 0;
      }
    }
  }
  if (ans)
    printf("YES\n%d\n", ans);
  else
    printf("NO\n");
  return 0;
}
