#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = int(1e5) + 10;
vector<int> g[N];
int C[N], cnt[N];
void dfs1(int u, int p) {
  cnt[u] = C[u];
  for (auto w : g[u])
    if (w != p) {
      dfs1(w, u);
      if (C[u] != cnt[w]) cnt[u] = -1;
    }
}
void dfs2(int u, int p, bool ok = true) {
  int c = 0;
  for (auto w : g[u])
    if (w != p && cnt[w] == -1) c++;
  if (c == 0) {
    puts("YES");
    printf("%d\n", u);
    exit(0);
  } else if (c > 1 || !ok) {
    puts("NO");
    exit(0);
  }
  for (auto w : g[u])
    if (w != p && cnt[w] != -1 && cnt[w] != C[u]) {
      puts("NO");
      exit(0);
    }
  for (auto w : g[u])
    if (w != p && cnt[w] == -1) dfs2(w, u, C[u] == C[w]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &C[i]);
  dfs1(1, 0);
  dfs2(1, 0);
  assert(false);
  return 0;
}
