#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const char YES[] = "YES";
const char NO[] = "NO";
vector<int> adj[100100], haveColor[100100];
int color[100100];
int par[100100], sta[100100], fin[100100], n, cnt;
void loadTree(void) {
  scanf("%d", &n);
  for (int love = 0, _n = (n - 1); love < _n; love = love + 1) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = (1), _b = (n); i <= _b; i = i + 1) {
    scanf("%d", &color[i]);
    haveColor[color[i]].push_back(i);
  }
}
void dfs(int u) {
  sta[u] = ++cnt;
  for (__typeof((adj[u]).begin()) it = (adj[u]).begin(); it != (adj[u]).end();
       it++)
    if (*it != par[u]) {
      par[*it] = u;
      dfs(*it);
    }
  fin[u] = cnt;
}
void answer(int node) {
  if (node > 0)
    printf("%s\n%d\n", YES, node);
  else
    printf("%s\n", NO);
  exit(0);
}
bool checkSubTree(int u) {
  int c = color[u];
  int L = lower_bound((haveColor[c]).begin(), (haveColor[c]).end(), sta[u]) -
          haveColor[c].begin();
  int R = upper_bound((haveColor[c]).begin(), (haveColor[c]).end(), fin[u]) -
          haveColor[c].begin();
  return R - L == fin[u] - sta[u] + 1;
}
bool checkParTree(int u) {
  if (u == 1) return true;
  int c = color[par[u]];
  int L = lower_bound((haveColor[c]).begin(), (haveColor[c]).end(), sta[u]) -
          haveColor[c].begin();
  int R = upper_bound((haveColor[c]).begin(), (haveColor[c]).end(), fin[u]) -
          haveColor[c].begin();
  return haveColor[c].size() - (R - L) == n - (fin[u] - sta[u] + 1);
}
bool checkNode(int u) {
  for (__typeof((adj[u]).begin()) it = (adj[u]).begin(); it != (adj[u]).end();
       it++) {
    if (par[*it] == u && !checkSubTree(*it)) return false;
    if (par[u] == *it && !checkParTree(u)) return false;
  }
  return true;
}
void process(void) {
  dfs(1);
  for (int i = 0, _n = (100100); i < _n; i = i + 1)
    if (!haveColor[i].empty()) {
      for (__typeof((haveColor[i]).begin()) it = (haveColor[i]).begin();
           it != (haveColor[i]).end(); it++)
        *it = sta[*it];
      sort((haveColor[i]).begin(), (haveColor[i]).end());
    }
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    if (checkNode(i)) answer(i);
  answer(-1);
}
int main(void) {
  loadTree();
  process();
  return 0;
}
