#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<pair<long long, long long>> adj;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    adj.push_back({u, v});
  }
  long long colors[n + 1];
  for (long long i = 1; i <= n; i++) cin >> colors[i];
  vector<pair<long long, long long>> magic;
  for (long long i = 0; i < n - 1; i++) {
    if (colors[adj[i].first] != colors[adj[i].second]) magic.push_back(adj[i]);
  }
  if (magic.size() == 0) {
    cout << "YES\n1" << '\n';
    return 0;
  }
  map<long long, long long> mp;
  for (auto x : magic) {
    mp[x.first]++;
    mp[x.second]++;
  }
  for (auto x : mp) {
    if (mp[x.first] == (long long)magic.size()) {
      cout << "YES\n" << x.first << '\n';
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
