#include <bits/stdc++.h>
using namespace std;
long long n;
vector<vector<long long>> adj;
vector<long long> arr;
long long vis[100005];
bool dfs(long long u, long long p) {
  vis[u] = 1;
  if (adj[u].size() == 1 && vis[adj[u][0]]) {
    return true;
  }
  bool ans = true;
  long long temp;
  for (long long x : adj[u]) {
    if (vis[x] == 0) {
      ans &= dfs(x, p);
      temp = x;
    }
  }
  if (u == p) return ans;
  return ans && (arr[u] == arr[temp]);
}
int main() {
  cin >> n;
  adj.resize(n + 2);
  arr.resize(n + 2);
  vector<pair<long long, long long>> edge;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    edge.push_back({x, y});
  }
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  pair<long long, long long> check = {0, 0};
  for (long long i = 0; i < edge.size(); i++) {
    if (arr[edge[i].first] != arr[edge[i].second]) {
      check = edge[i];
      break;
    }
  }
  if (check.first == 0) {
    cout << "YES\n1\n";
    return 0;
  }
  if (dfs(check.first, check.first)) {
    cout << "YES\n";
    cout << check.first;
    return 0;
  }
  memset(vis, 0, sizeof vis);
  if (dfs(check.second, check.second)) {
    cout << "YES\n";
    cout << check.second;
  } else
    cout << "NO";
  cout << "\n";
}
