#include <bits/stdc++.h>
using namespace std;
long long int n, i, j, t;
int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  ;
  cin >> n;
  vector<bool> used(n + 1, false);
  vector<vector<long long int> > adj(n + 1, vector<long long int>());
  vector<long long int> c(n + 1);
  vector<long long int> degree(n + 1);
  long long int u, v;
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    degree[u]++;
    degree[v]++;
  }
  long long int f;
  for (i = 1; i <= n; i++) cin >> c[i];
  queue<long long int> q;
  q.push(1);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    used[u] = true;
    for (auto v : adj[u]) {
      if (!used[v]) q.push(v);
      if (c[v] != c[u]) {
        f = v;
        while (!q.empty()) q.pop();
        break;
      }
    }
  }
  v = u;
  for (i = 1; i <= n; i++) used[i] = false;
  used[v] = true;
  long long int e = 0, a;
  for (auto u : adj[v]) {
    queue<long long int> q;
    q.push(u);
    while (!q.empty()) {
      a = q.front();
      q.pop();
      used[a] = true;
      for (auto b : adj[a]) {
        if (!used[b]) {
          q.push(b);
          if (c[b] != c[u]) e = -1;
        }
      }
    }
  }
  if (e == 0) {
    cout << "YES" << '\n' << v << '\n';
  } else {
    for (i = 1; i <= n; i++) used[i] = false;
    used[f] = true;
    for (auto u : adj[f]) {
      queue<long long int> q;
      q.push(u);
      while (!q.empty()) {
        a = q.front();
        q.pop();
        used[a] = true;
        for (auto b : adj[a]) {
          if (!used[b]) {
            if (c[b] != c[u]) {
              cout << "NO\n";
              return 0;
            }
            q.push(b);
          }
        }
      }
    }
    cout << "YES\n" << f << '\n';
  }
}
