#include <bits/stdc++.h>
using namespace std;
std::vector<long long> adj[200005];
long long colours[200005];
long long check;
long long sub_color;
void dfs(long long u, long long parent) {
  check = check && (colours[u] == sub_color);
  for (auto child : adj[u]) {
    if (child != parent) {
      dfs(child, u);
    }
  }
}
long long solve(long long vertex) {
  long long isPossible = true;
  for (auto child : adj[vertex]) {
    sub_color = colours[child];
    check = true;
    dfs(child, vertex);
    isPossible = isPossible && check;
  }
  return isPossible;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long u, v;
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bool allSame = true;
  long long first, second;
  for (long long i = 0; i < n; i++) {
    cin >> colours[i];
  }
  for (long long i = 0; i < n; i++) {
    for (auto child : adj[i]) {
      if (colours[i] != colours[child]) {
        first = i;
        second = child;
        allSame = false;
      }
    }
  }
  if (allSame) {
    cout << "YES"
         << "\n";
    cout << 1 << "\n";
    return 0;
  }
  long long b1 = solve(first);
  long long b2 = solve(second);
  if (b1) {
    cout << "YES"
         << "\n";
    cout << first + 1 << "\n";
  } else if (b2) {
    cout << "YES"
         << "\n";
    cout << second + 1 << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
  return 0;
}
