#include <bits/stdc++.h>
using namespace std;
long long t, n, m, u, v, q, r, ql, qr, k, l, w, x, y, d, c, a, s;
const int N = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 61LL;
vector<int> adj[N];
int C[N];
int cnt[N];
bool same_sub[N];
int sz[N];
bool valid = false;
int root = -1;
void dfs(int v, int p) {
  same_sub[v] = true;
  bool h = true;
  sz[v] = 1;
  for (int u : adj[v]) {
    if (u == p) continue;
    dfs(u, v);
    if (C[u] != C[v] || !same_sub[u]) {
      same_sub[v] = false;
    }
    sz[v] += sz[u];
    if (!same_sub[u]) h = false;
  }
  if (h) {
    cnt[C[v]]--;
    for (int u : adj[v]) {
      if (u == p) continue;
      cnt[C[u]] -= sz[u];
    }
    if (cnt[C[p]] == n - sz[v]) {
      valid = true;
      root = v;
    }
    for (int u : adj[v]) {
      if (u == p) continue;
      cnt[C[u]] += sz[u];
    }
    cnt[C[v]]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> C[i];
    cnt[C[i]]++;
  }
  C[0] = 0;
  cnt[0] = 0;
  dfs(1, 0);
  if (valid)
    cout << "YES\n";
  else {
    cout << "NO\n";
    return 0;
  }
  cout << root << '\n';
  return 0;
}
