#include <bits/stdc++.h>
using namespace std;
void dfs(int x, int p, const vector<vector<int> > &g, const vector<int> &c,
         vector<int> &sub) {
  vector<int> sons;
  for (int dest : g[x])
    if (dest != p) {
      dfs(dest, x, g, c, sub);
      sons.push_back(dest);
    }
  sub[x] = c[x];
  for (int dest : sons)
    if (sub[dest] == -1 || sub[dest] != sub[x]) sub[x] = -1;
}
void dfs_ans(int x, int p, const vector<vector<int> > &g, const vector<int> &c,
             const vector<int> &sub, vector<char> &ans) {
  vector<int> sons;
  for (int dest : g[x])
    if (dest != p) sons.push_back(dest);
  ans[x] = 1;
  for (int dest : sons) ans[x] &= (sub[dest] != -1);
  bool can = (p == -1 ? true : c[p] == c[x]);
  int cnt = 0;
  for (int dest : sons) cnt += (c[x] == sub[dest]);
  if (!can || cnt + 1 < (int)(sons).size()) return;
  if (cnt + 1 == (int)(sons).size()) {
    int to = -1;
    for (int dest : sons)
      if (sub[dest] != c[x]) to = dest;
    assert(to != -1);
    dfs_ans(to, x, g, c, sub, ans);
  } else if (cnt == (int)(sons).size()) {
    for (int dest : sons) dfs_ans(dest, x, g, c, sub, ans);
  }
}
void solve(int n) {
  vector<vector<int> > g(n);
  for (int i = 0; i < int(n - 1); ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> c(n), sub(n);
  for (int i = 0; i < int(n); ++i) cin >> c[i];
  dfs(0, -1, g, c, sub);
  vector<char> ans(n, 0);
  dfs_ans(0, -1, g, c, sub, ans);
  int pos = find((ans).begin(), (ans).end(), 1) - ans.begin();
  if (pos != (int)(ans).size()) {
    cout << "YES" << endl;
    cout << pos + 1 << endl;
  } else
    cout << "NO" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n) solve(n);
}
