#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
map<int, int> mp;
map<int, int> mp1;
vector<int> rt;
int c[100005];
bool vis[100005];
bool bfs(int nd) {
  int col = c[nd];
  int fg = 0;
  queue<int> q;
  vis[nd] = true;
  q.push(nd);
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (int i = 0; i < adj[node].size(); i++) {
      if (!vis[adj[node][i]]) {
        if (c[adj[node][i]] != col) {
          fg = 1;
        }
        vis[adj[node][i]] = true;
        q.push(adj[node][i]);
      }
    }
  }
  if (fg == 0)
    return true;
  else
    return false;
}
int ua[100005], va[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    ua[i] = u;
    va[i] = v;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    if (c[ua[i]] != c[va[i]]) {
      memset(vis, false, sizeof(vis));
      int fg = 0;
      vis[ua[i]] = true;
      for (int j = 0; j < adj[ua[i]].size(); j++) {
        bool x1 = bfs(adj[ua[i]][j]);
        if (x1 == false) {
          fg = 1;
          break;
        }
      }
      if (fg == 0) {
        printf("YES\n");
        printf("%d\n", ua[i]);
        return 0;
      } else {
        memset(vis, false, sizeof(vis));
        vis[va[i]] = true;
        fg = 0;
        for (int j = 0; j < adj[va[i]].size(); j++) {
          bool x2 = bfs(adj[va[i]][j]);
          if (x2 == false) {
            fg = 1;
            break;
          }
        }
        if (fg == 0) {
          printf("YES\n");
          printf("%d\n", va[i]);
          return 0;
        } else {
          printf("NO\n");
          return 0;
        }
      }
    }
  }
  printf("YES\n1\n");
  return 0;
}
