#include <bits/stdc++.h>
using namespace std;
const long long mxN = 1 + 100 * 1000;
vector<long long> v[mxN];
vector<long long> c(mxN);
vector<bool> vis(mxN);
vector<bool> node(mxN);
signed main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long>> edges;
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    edges.push_back({a, b});
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
  }
  set<long long> diff;
  vector<long long> deg(mxN);
  for (auto x : edges) {
    if (c[x.first] != c[x.second]) {
      diff.insert(x.first);
      diff.insert(x.second);
      deg[x.first]++;
      deg[x.second]++;
    }
  }
  if (diff.size() == 0) {
    cout << "YES\n";
    cout << 1 << endl;
    return 0;
  }
  long long ma = *max_element(deg.begin(), deg.end());
  assert(ma != 0);
  long long p;
  for (long long i = 0; i < n; i++) {
    if (deg[i] == ma) {
      p = i;
      break;
    }
  }
  set<long long> check;
  for (long long i = 0; i < n; i++) {
    if (i != p && deg[i] > 0) check.insert(deg[i]);
  }
  if (check.size() > 1) {
    cout << "NO\n";
    return 0;
  }
  long long root = p;
  queue<long long> q;
  for (auto u : v[root]) {
    q.push(u);
    vis[u] = true;
  }
  vis[root] = true;
  bool f = 0;
  while (!q.empty()) {
    long long s = q.front();
    q.pop();
    long long color = c[s];
    set<long long> st2;
    st2.insert(color);
    for (auto u : v[s]) {
      if (!vis[u]) {
        q.push(u);
        vis[u] = true;
        st2.insert(c[u]);
      }
    }
    if (st2.size() != 1) f = 1;
  }
  if (!f) {
    cout << "YES\n";
    cout << root + 1 << endl;
  } else
    cout << "NO\n";
}
