#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<vector<int> > v(N);
int col[N];
int par[N];
int n;
int in[N], out[N];
int timer;
bool all_same[N];
bool can[N];
int euler[2 * N];
int tree[8 * N];
int answer = -1;
void dfs(int node) {
  all_same[node] = true;
  can[node] = true;
  timer++;
  in[node] = timer;
  euler[timer] = col[node];
  for (int to : v[node]) {
    if (to == par[node]) continue;
    par[to] = node;
    dfs(to);
    can[node] &= (all_same[to]);
    all_same[node] &= (all_same[to] and (col[node] == col[to]));
  }
  out[node] = timer;
}
void build(int id, int lo, int hi) {
  if (lo == hi) {
    tree[id] = euler[lo];
    return;
  }
  int mid = (lo + hi) >> 1;
  build(2 * id, lo, mid);
  build(2 * id + 1, mid + 1, hi);
  if (tree[2 * id + 1] == tree[2 * id]) tree[id] = tree[2 * id];
}
int query(int id, int lo, int hi, int l, int r) {
  if (r < l) return -2;
  if (l > hi or r < lo) return -2;
  if (l <= lo and r >= hi) {
    if (tree[id] == 0) return -1;
    return (tree[id]);
  }
  int mid = (lo + hi) >> 1;
  int tmp1 = query(2 * id, lo, mid, l, r);
  int tmp2 = query(2 * id + 1, mid + 1, hi, l, r);
  if (tmp1 == tmp2) {
    return tmp1;
  }
  if (tmp1 == -2) {
    return tmp2;
  }
  if (tmp2 == -2) {
    return tmp1;
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[x].emplace_back(y);
    v[y].emplace_back(x);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &col[i]);
  }
  dfs(1);
  build(1, 1, timer);
  for (int i = 1; i <= n; i++) {
    if (can[i]) {
      int node = i;
      int tmp1 = query(1, 1, timer, 1, in[node] - 1);
      int tmp2 = query(1, 1, timer, out[node] + 1, timer);
      if ((tmp1 == tmp2 and tmp1 != -1) or (tmp1 == -2 and tmp2 != -1) or
          (tmp1 != -1 and tmp2 == -2)) {
        puts("YES");
        printf("%d\n", i);
        return 0;
      }
    }
  }
  puts("NO");
}
