#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 20;
struct node {
  int u, v, tonext;
} e[maxn];
int num;
int first[maxn];
void add(int u, int v) {
  num++;
  e[num].u = u;
  e[num].v = v;
  e[num].tonext = first[u];
  first[u] = num;
}
int c[maxn], in[maxn];
int u[maxn], v[maxn];
set<int> ss;
int vis[maxn];
int DFN;
int dfs(int cur, int no) {
  ss.insert(c[cur]);
  if (ss.size() >= 2) return false;
  bool flag = true;
  for (int i = first[cur]; i; i = e[i].tonext) {
    if (e[i].v == no) continue;
    if (vis[e[i].v] == DFN) continue;
    vis[e[i].v] = DFN;
    flag = flag && dfs(e[i].v, no);
  }
  return flag;
}
bool del(int cur) {
  for (int i = first[cur]; i; i = e[i].tonext) {
    ss.clear();
    DFN++;
    vis[cur] = DFN;
    vis[e[i].v] = DFN;
    if (dfs(e[i].v, (0x3f3f3f3f)) == false) return false;
  }
  return true;
}
void work() {
  int n;
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> u[i] >> v[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
  }
  int which = (0x3f3f3f3f);
  for (int i = 1; i <= n - 1; ++i) {
    if (c[u[i]] != c[v[i]] && which == (0x3f3f3f3f)) which = i;
    add(u[i], v[i]);
    add(v[i], u[i]);
  }
  if (which == (0x3f3f3f3f)) {
    cout << "YES" << endl;
    cout << 1 << endl;
    return;
  }
  if (del(u[which])) {
    cout << "YES" << endl;
    cout << u[which] << endl;
    return;
  }
  if (del(v[which])) {
    cout << "YES" << endl;
    cout << v[which] << endl;
    return;
  }
  cout << "NO" << endl;
}
int main() {
  work();
  return 0;
}
