#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> adj;
  int color, bl = 0;
  int no_diff_edge = 0;
};
int dfs(int u, int color, vector<node> &tree) {
  int ans = 1;
  for (auto x : tree[u].adj) {
    if (tree[x].bl == 0 && tree[x].color != color) {
      tree[x].bl = 1;
      return 0;
    } else if (tree[x].bl == 0) {
      tree[x].bl = 1;
      ans = ans & dfs(x, color, tree);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  int n;
  cin >> n;
  vector<node> tree(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    tree[u].adj.push_back(v);
    tree[v].adj.push_back(u);
  }
  for (int i = 0; i < n; i++) cin >> tree[i + 1].color;
  map<int, int> colors;
  for (int i = 1; i < n + 1; i++) colors.insert({tree[i].color, 0});
  int ans = 1;
  for (int i = 1; i < n + 1; i++) {
    int color = tree[i].color;
    for (auto x : tree[i].adj)
      if (tree[x].color != color) tree[i].no_diff_edge++;
    if (tree[ans].no_diff_edge < tree[i].no_diff_edge) ans = i;
  }
  tree[ans].bl = 1;
  for (auto x : tree[ans].adj) {
    tree[x].bl = 1;
    if (dfs(x, tree[x].color, tree) == 0) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  cout << ans << "\n";
  return 0;
}
