#include <bits/stdc++.h>
using namespace std;
vector<int> g[100500];
int c[100500];
int n;
bool vis[100500];
bool dfs(int u, int cu) {
  if (vis[u]) return 0;
  vis[u] = 1;
  bool r = 0;
  if (c[u] != cu) return 1;
  for (int v : g[u]) r |= dfs(v, cu);
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 0, qwe = n - 1; i < qwe; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0, qwe = n; i < qwe; ++i) scanf("%d", c + i);
  int u = -1, sz = 0;
  for (int i = 0, qwe = n; i < qwe; ++i) {
    set<int> s;
    for (int v : g[i])
      if (c[i] != c[v]) s.insert(v);
    if (s.size() > sz) u = i, sz = s.size();
  }
  if (u == -1) {
    puts("YES\n1");
    return 0;
  }
  vis[u] = 1;
  for (int i = 0, qwe = g[u].size(); i < qwe; ++i)
    if (dfs(g[u][i], c[g[u][i]])) {
      puts("NO");
      return 0;
    }
  printf("YES\n%d\n", u + 1);
  return 0;
}
