#include <bits/stdc++.h>
using namespace std;
long long int n, a[100005], ctrr[100005], mark[100005], par[100005], sz[100005];
vector<long long int> nb[100005];
vector<long long int> ans;
void dfs(long long int st, long long int pr) {
  bool ch = 1, ch2 = 1;
  par[st] = pr;
  sz[st] = 1;
  for (long long int v : nb[st]) {
    if (v == pr) continue;
    dfs(v, st);
    if (!mark[v] || a[v] != a[st]) ch = 0;
    if (!mark[v]) ch2 = 0;
    sz[st] += sz[v];
  }
  if (ch == 1) mark[st] = 1;
  if (ch2 == 1) ans.push_back(st);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n - 1; ++i) {
    long long int u, v;
    cin >> u >> v;
    nb[u].push_back(v);
    nb[v].push_back(u);
  }
  set<long long int> clr;
  for (long long int i = 1; i <= n; ++i)
    cin >> a[i], ctrr[a[i]]++, clr.insert(a[i]);
  dfs(1, 1);
  if (ans.empty()) {
    cout << "NO";
    return 0;
  }
  sort(ans.begin(), ans.end());
  if (ans[0] == 1) {
    cout << "YES\n1";
    return 0;
  }
  for (long long int v : ans) {
    for (long long int u : nb[v]) {
      if (u == par[v]) continue;
      ctrr[a[u]] -= sz[u];
    }
    ctrr[a[v]]--;
    set<long long int> tem1, tem2;
    long long int ct = 0;
    for (long long int u : nb[v]) {
      if (u == par[v]) continue;
      if (ctrr[a[u]]) tem1.insert(a[u]);
      tem2.insert(a[u]);
    }
    if (ctrr[a[v]]) tem1.insert(a[v]);
    tem2.insert(a[v]);
    if (tem1.empty()) {
      long long int xx1 = tem2.size();
      long long int xx2 = clr.size();
      if (xx2 == xx1 + 1) {
        cout << "YES" << endl << v;
        return 0;
      }
    }
    if (tem1.size() == 1) {
      long long int xx1 = tem2.size();
      long long int xx2 = clr.size();
      if (xx2 == xx1) {
        cout << "YES" << endl << v;
        return 0;
      }
    }
    for (long long int u : nb[v]) {
      if (u == par[v]) continue;
      ctrr[a[u]] += sz[u];
    }
    ctrr[a[v]]++;
  }
  cout << "NO";
}
