#include <bits/stdc++.h>
using namespace std;
bool check(long long int child, vector<long long int> adj[],
           vector<long long int> &vis, vector<long long int> &c) {
  vis[child] = 1;
  for (long long int i = 0; i < adj[child].size(); i++) {
    long long int y = adj[child][i];
    if (!vis[y]) {
      vis[y] = 1;
      if (c[child] != c[y] || !check(y, adj, vis, c)) return false;
    }
  }
  return true;
}
bool dfs(long long int child, vector<long long int> adj[],
         vector<long long int> &vis, vector<long long int> &c) {
  for (long long int i = 1; i < vis.size(); i++) vis[i] = 0;
  vis[child] = 1;
  for (long long int i = 0; i < adj[child].size(); i++) {
    long long int y = adj[child][i];
    if (!check(y, adj, vis, c)) return false;
  }
  return true;
}
int32_t main() {
  long long int t = 0;
  t = 1;
  while (t--) {
    long long int n = 0;
    cin >> n;
    vector<long long int> adj[n + 1];
    vector<long long int> vis(n + 1, 0);
    pair<long long int, long long int> edge[n + 1];
    for (long long int i = 1; i < n; i++) {
      long long int u = 0;
      long long int v = 0;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
      edge[i] = {u, v};
    }
    vector<long long int> c(n + 1, 0);
    for (long long int i = 1; i <= n; i++) cin >> c[i];
    long long int a = -1;
    long long int b = -1;
    long long int count = 0;
    for (long long int i = 1; i < n; i++) {
      long long int x = edge[i].first;
      long long int y = edge[i].second;
      if (c[x] != c[y]) {
        if (count > 0 && !(a != x && a != y && b != x && b != y)) count--;
        count++;
        a = x;
        b = y;
      }
    }
    if (count == 0) {
      cout << "YES" << endl;
      cout << 1 << endl;
      return 0;
    } else if (count > 1) {
      cout << "NO" << endl;
      return 0;
    } else if (dfs(a, adj, vis, c)) {
      cout << "YES" << endl;
      cout << a << endl;
      return 0;
    } else if (dfs(b, adj, vis, c)) {
      cout << "YES" << endl;
      cout << b << endl;
      return 0;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
