#include <bits/stdc++.h>
using namespace std;
const int inf = 1.01e9;
const double eps = 1e-9;
const int N = 2e5 + 10;
vector<int> v[N];
int c[N];
pair<int, int> dfs(int x, int pr) {
  pair<int, int> res = {c[x], c[x]};
  for (int y : v[x])
    if (y != pr) {
      pair<int, int> t = dfs(y, x);
      res.first = min(res.first, t.first);
      res.second = max(res.second, t.second);
    }
  return res;
}
void check(int x) {
  for (int y : v[x]) {
    pair<int, int> z = dfs(y, x);
    if (z.first != z.second) return;
  }
  printf("YES\n%d\n", x + 1);
  exit(0);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; (i) < (n - 1); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x, --y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 0; (i) < (n); ++i) scanf("%d", &c[i]);
  for (int i = 0; (i) < (n); ++i)
    for (int j : v[i])
      if (c[i] != c[j]) {
        check(i);
        check(j);
        printf("NO\n");
        return 0;
      }
  printf("YES\n1\n");
  return 0;
}
