#include <bits/stdc++.h>
using namespace std;
const int maxn = 100009;
pair<int, int> E[maxn];
vector<int> neigh[maxn];
int col[maxn];
bool dfs(int v, int p) {
  bool ok = true;
  for (int u : neigh[v]) {
    if (u == p) continue;
    if (p != 0 && col[v] != col[u]) return false;
    ok = ok && dfs(u, v);
  }
  return ok;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &E[i].first, &E[i].second);
    neigh[E[i].first].push_back(E[i].second);
    neigh[E[i].second].push_back(E[i].first);
  }
  for (int v = 1; v <= n; v++) scanf("%d", &col[v]);
  int e = 0;
  while (e < n - 2 && col[E[e].first] == col[E[e].second]) e++;
  if (dfs(E[e].first, 0)) {
    printf("YES\n");
    printf("%d\n", E[e].first);
  } else if (dfs(E[e].second, 0)) {
    printf("YES\n");
    printf("%d\n", E[e].second);
  } else {
    printf("NO");
  }
}
