#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
vector<int> gr[N];
int c[N];
int cmx[N];
bool twoclrs[N];
void dfs(int v, int fr) {
  twoclrs[v] = false;
  for (auto u : gr[v]) {
    if (u == fr) continue;
    dfs(u, v);
    twoclrs[v] |= twoclrs[u] or c[u] != c[v];
  }
}
int dig(int v, int fr) {
  int nxt = 0;
  bool candig = fr ? c[fr] == c[v] : true;
  for (auto u : gr[v]) {
    if (u == fr) continue;
    if (twoclrs[u]) {
      if (nxt) return -1;
      nxt = u;
    } else {
      candig &= c[v] == c[u];
    }
  }
  if (nxt == 0) return v;
  if (not candig) return -1;
  return dig(nxt, v);
}
int go() {
  dfs(1, 0);
  return dig(1, 0);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0, u, v; i < n - 1; ++i) {
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) cin >> c[i];
  int ans = go();
  if (ans == -1) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    cout << ans << '\n';
  }
}
