#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
const int inf = 0x3f3f3f3f;
int n, m;
int vis[MAXN];
int color[MAXN];
vector<int> G[MAXN];
map<int, int> du;
int cnt;
int main() {
  int i, j, l;
  scanf("%d", &n);
  int u, v;
  for (i = 0; i < n - 1; ++i) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
  }
  cnt = 0;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &color[i]);
  }
  for (i = 1; i <= n; ++i)
    for (j = 0, l = G[i].size(); j < l; ++j) {
      int v = G[i][j];
      if (color[i] != color[v]) {
        du[i]++;
        du[v]++;
        cnt++;
      }
    }
  if (!cnt)
    printf("YES\n%d\n", 1);
  else {
    int flag = 0;
    for (auto it : du) {
      if (it.second == cnt) {
        printf("YES\n%d\n", it.first);
        flag = 1;
        break;
      }
    }
    if (!flag) puts("NO");
  }
  return 0;
}
