#include <bits/stdc++.h>
using namespace std;
vector<int> groups;
int get_group(int u) {
  while (u != groups[u]) u = groups[u];
  return u;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int> > e(n - 1);
  vector<int>* al = new vector<int>[n];
  for (int i = 0; i < n - 1; ++i) {
    cin >> e[i].first >> e[i].second;
    --e[i].first;
    --e[i].second;
    al[e[i].first].push_back(e[i].second);
    al[e[i].second].push_back(e[i].first);
  }
  vector<int> c(n);
  for (int i = 0; i < n; ++i) cin >> c[i];
  groups.resize(n);
  for (int i = 0; i < n; ++i) groups[i] = i;
  for (int i = 0; i < n - 1; ++i) {
    int u = e[i].first;
    int v = e[i].second;
    if (c[u] == c[v]) {
      int u_group = get_group(u);
      int v_group = get_group(v);
      groups[max(u_group, v_group)] = min(u_group, v_group);
    }
  }
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i) {
    int group_i = get_group(i);
    for (int j = 0, m = al[i].size(); j < m; ++j) {
      int group_j = get_group(al[i][j]);
      if (group_j != group_i) ++cnt[i];
    }
  }
  int res = -1;
  int total = 0;
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    if (cnt[i] > 1) {
      if (res == -1) {
        res = i;
      } else {
        ok = false;
        break;
      }
    }
    total += cnt[i];
  }
  if (!ok) {
    cout << "NO" << endl;
    return 0;
  }
  if (res == -1) {
    for (int i = 0; i < n; ++i) {
      if (cnt[i] == 1) {
        res = i;
        break;
      }
    }
  }
  if (res != -1 && cnt[res] * 2 != total) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  cout << (res == -1 ? 1 : res + 1) << endl;
  return 0;
}
