#include <bits/stdc++.h>
using namespace std;
long long id = -1;
void dfs(long long now, long long p, const vector<vector<long long>>& mas,
         vector<long long>& col, vector<long long>& dp) {
  for (auto to : mas[now]) {
    if (to != p) {
      dfs(to, now, mas, col, dp);
      dp[now] &= dp[to];
      dp[now] &= (col[now] == col[to]);
    }
  }
  bool f = 1;
  for (auto to : mas[now])
    if (to != p)
      if (!dp[to]) f = 0;
  if (!dp[now] && f && id == -1) id = now;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> mas(n);
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    mas[u - 1].push_back(v - 1);
    mas[v - 1].push_back(u - 1);
  }
  vector<long long> col(n);
  for (auto& it : col) cin >> it;
  vector<long long> dp(n, 1);
  dfs(0, -1, mas, col, dp);
  if (dp[0] == 1) {
    cout << "YES" << endl;
    cout << 1 << endl;
    return 0;
  }
  dp.assign(n, 1);
  dfs(id, -1, mas, col, dp);
  bool f = 1;
  for (auto to : mas[id]) {
    if (dp[to] != 1) f = 0;
  }
  cout << (f ? "YES\n" + to_string(id + 1) : "NO");
}
