#include <bits/stdc++.h>
using namespace std;
vector<int> v[123424];
int c[123412];
map<pair<int, int>, bool> e;
bool tiitvojadjeca(int p, int i, int k) {
  bool ans = 1;
  for (auto x : v[i]) {
    if (x == p) continue;
    if (e.count(make_pair(i, x)))
      ans &= e[make_pair(i, x)];
    else if (c[x] == k) {
      ans &= tiitvojadjeca(i, x, c[x]);
      e[make_pair(i, x)] = ans;
    } else
      return false;
    if (!ans) return false;
  }
  return true;
}
bool inves(int i) {
  bool ans = 1;
  for (auto x : v[i]) {
    ans &= tiitvojadjeca(i, x, c[x]);
    if (!ans) return false;
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int t, p;
    scanf("%d %d", &t, &p);
    v[t].push_back(p);
    v[p].push_back(t);
  }
  for (int i = 1; i <= n; ++i) scanf("%d", c + i);
  for (int i = 1; i <= n; ++i) {
    if (inves(i)) {
      return !printf("YES\n%d", i);
    }
  }
  printf("NO");
  return 0;
}
