#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int n, col[100005];
vector<int> adj[100005], adjacent;
set<int> distinct_;
void dfs(int v, int par) {
  for (auto vv : adj[v])
    if (vv != par) {
      if (col[v] != col[vv]) {
        adjacent.push_back(v);
        adjacent.push_back(vv);
      }
      dfs(vv, v);
    }
}
void verify(int v, int par) {
  distinct_.insert(col[v]);
  for (auto vv : adj[v])
    if (vv != par) verify(vv, v);
}
bool check(int v) {
  for (auto vv : adj[v]) {
    distinct_.clear();
    verify(vv, v);
    if ((int)distinct_.size() > 1) return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  int e = n - 1;
  while (e--) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &col[i]);
    distinct_.insert(col[i]);
  }
  if ((int)distinct_.size() == 1) {
    printf("YES\n");
    printf("1\n");
    return 0;
  }
  if (check(1)) {
    printf("YES\n");
    printf("1\n");
    return 0;
  }
  dfs(1, -1);
  if (adjacent.empty()) {
    printf("YES\n");
    printf("1\n");
    return 0;
  }
  if (check(adjacent[0])) {
    printf("YES\n");
    printf("%d\n", adjacent[0]);
    return 0;
  }
  if (check(adjacent[1])) {
    printf("YES\n");
    printf("%d\n", adjacent[1]);
    return 0;
  }
  printf("NO\n");
  return 0;
}
