#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> ds[N];
int deg[N], c[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    ds[u].push_back(v);
    ds[v].push_back(u);
    deg[u]++;
    deg[v]++;
  }
  for (int i = 1; i <= n; i++) scanf("%d", c + i);
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (deg[i] == 1) {
      q.push(i);
    }
  int ans = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    deg[u] = 0;
    for (auto &v : ds[u]) {
      if (deg[v] <= 0) continue;
      if (c[v] != c[u]) {
        if (ans > 0 && ans != v) {
          printf("NO");
          return 0;
        }
        ans = v;
        continue;
      }
      deg[v]--;
      if (deg[v] == 1) {
        q.push(v);
      }
    }
  }
  if (ans == 0)
    printf("YES\n1");
  else {
    printf("YES\n%d", ans);
  }
}
