#include <bits/stdc++.h>
using namespace std;
vector<int> q[250000];
int color[250000];
int a[250000], b[250000];
int ssum[250000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &color[i]);
  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    if (color[a[i]] != color[b[i]]) {
      ssum[a[i]]++;
      ssum[b[i]]++;
      sum++;
    }
  }
  int flag = 0;
  for (int i = 1; i <= n; i++)
    if (sum - ssum[i] == 0) {
      flag = i;
      break;
    }
  if (flag)
    printf("YES\n%d", flag);
  else
    printf("NO");
}
