#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = (int)1e5 + 5;
int n;
int c[maxn], df[maxn];
vector<int> adj[maxn];
vector<int> outer_nodes;
void dfs(int cur, unordered_set<int>& viz) {
  for (int nei : adj[cur]) {
    if (c[cur] == c[nei]) continue;
    if (viz.find(nei) != viz.end()) continue;
    viz.insert(nei);
    dfs(nei, viz);
  }
}
int count_outer(int root) {
  unordered_set<int> viz;
  viz.insert(root);
  dfs(root, viz);
  return viz.size();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) {
    int me = c[i];
    bool added = false;
    for (auto nei : adj[i]) {
      if (me != c[nei]) {
        if (!added) outer_nodes.push_back(i);
        added = true;
        df[i]++;
      }
    }
  }
  if (outer_nodes.empty()) {
    cout << "YES" << endl;
    cout << 1 << endl;
    return 0;
  }
  int count = count_outer(outer_nodes.front());
  if (count != (int)outer_nodes.size()) out("NO");
  for (int& x : outer_nodes) {
    if (df[x] == count - 1) {
      cout << "YES" << endl;
      cout << x + 1 << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
