#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
int n, m, a[maxn], b[maxn], c[maxn];
map<int, int> M, N;
string s, ss;
set<int> S;
vector<pair<int, int> > edges;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i < n; i++)
    if (c[a[i]] != c[b[i]]) edges.push_back({a[i], b[i]});
  if (edges.size() == 0) {
    cout << "YES\n1\n";
    return 0;
  }
  if (edges.size() == 1) {
    cout << "YES\n" << edges[0].first << "\n";
    return 0;
  } else {
    int ans = -1;
    for (auto u : edges) M[u.first]++, M[u.second]++;
    for (int i = 1; i <= n; i++)
      if (M[i] == edges.size()) ans = i;
    if (ans != -1) {
      cout << "YES\n" << ans << "\n";
      return 0;
    }
  }
  cout << "NO\n";
}
