#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
int close_sycn = (ios::sync_with_stdio(false), cin.tie(0), 0);
int main() {
  int n, u, v;
  cin >> n;
  vector<P> edges(n - 1);
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    edges[i] = P(u - 1, v - 1);
  }
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  for (auto &p : edges) {
    u = p.first;
    v = p.second;
    if (a[u] != a[v]) {
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  int root = n;
  for (auto &p : edges) {
    u = p.first;
    v = p.second;
    if (root != n && (u == root || v == root)) continue;
    if (a[u] != a[v]) {
      if (root != n) {
        root = -1;
        break;
      }
      root = (g[u].size() > g[v].size() ? u : v);
    }
  }
  if (root == -1)
    cout << "NO\n";
  else
    cout << "YES\n" << (root == n ? 1 : root + 1) << '\n';
  return 0;
}
