#include <bits/stdc++.h>
using namespace std;
int n, u, v, cnt = 0, ans = -1;
vector<pair<int, int> > arr(1e5 + 5);
vector<int> color(1e5 + 5), dp(1e5 + 5, 0);
int main(void) {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> u >> v;
    arr[i] = {u, v};
  }
  for (int i = 1; i <= n; ++i) {
    cin >> color[i];
  }
  for (int i = 1; i <= n - 1; ++i) {
    if (color[arr[i].first] != color[arr[i].second]) {
      ++cnt;
      ++dp[arr[i].first];
      ++dp[arr[i].second];
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (dp[i] == cnt) {
      ans = i;
    }
  }
  if (ans == -1) {
    cout << "NO"
         << "\n";
  } else {
    cout << "YES"
         << "\n";
    cout << ans << "\n";
  }
  return 0;
}
