#include <bits/stdc++.h>
using namespace std;
long double const pi = 3.141592653589793238462;
long long int const mod = 1e9 + 7;
long long int const mod1 = 1e9 + 6;
long long int power(long long int a, long long int b) {
  long long int f = 1;
  while (b > 0) {
    if (b & 1) {
      f = f * a;
      f %= mod;
    }
    a = a * a;
    a %= mod;
    b = b / 2;
  }
  return f;
}
long long int inverse_mod(long long int x) { return power(x, mod - 2); }
long long int const N = 1e5 + 5;
vector<long long int> adj[N];
long long int col[N];
long long int is[N];
long long int ans;
void dfs(long long int in, long long int p) {
  is[in] = 1;
  for (auto x : adj[in]) {
    if (x == p) continue;
    dfs(x, in);
    if (col[x] != col[in] || is[x] == 0) is[in] = 0;
  }
}
void dfs1(long long int in, long long int p) {
  long long int res = 1;
  long long int cnt = 0;
  long long int y = 0;
  for (auto x : adj[in]) {
    if (x == p) continue;
    if (is[x] == 0) {
      res = 0;
      cnt++;
      y = x;
    }
  }
  if (res == 1) {
    ans = in;
    return;
  }
  if (cnt >= 2) {
    return;
  }
  is[in] = 1;
  for (auto x : adj[in]) {
    if (x == y) continue;
    if (is[x] == 0 || col[in] != col[x]) is[in] = 0;
  }
  if (is[in]) {
    dfs1(y, 0);
  }
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, i, j, l;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (i = 1; i <= n; i++) cin >> col[i];
  dfs(1, 0);
  dfs1(1, 0);
  if (ans) {
    cout << "YES" << endl;
    cout << ans << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
