#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int lj[200010], fro[200010], to[200010], cnt;
void add(int a, int b) {
  fro[++cnt] = lj[a];
  to[cnt] = b;
  lj[a] = cnt;
}
int n, c[200010], mz, tc[200010], ji[200010];
bool f = 1, tt[200010];
void dfs(int x, int fa) {
  tc[x] = c[x];
  for (int i = lj[x]; i; i = fro[i]) {
    if (to[i] == fa) continue;
    dfs(to[i], x);
    if ((!tt[to[i]] && tc[to[i]] == tc[x]) || mz == to[i])
      continue;
    else {
      if (mz && mz != x) f = 0;
      tt[x] = 1;
      mz = x;
    }
  }
}
int main() {
  n = rd();
  for (int i = 1, x, y; i < n; i++) {
    x = rd();
    y = rd();
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; i++) c[i] = rd(), ji[c[i]]++;
  dfs(1, 0);
  if (f && !mz) mz = 1;
  if (!f)
    puts("NO");
  else
    printf("YES\n%d\n", mz);
  return 0;
}
