#include <bits/stdc++.h>
using namespace std;
vector<int> d[100010];
vector<pair<int, int> > h;
int c[100010], vis[100010];
int main() {
  int n, u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    h.push_back(make_pair(u, v));
  }
  for (int i = 1; i <= n; i++) scanf("%d", c + i);
  for (int i = 0; i < h.size(); i++) {
    if (c[h[i].first] != c[h[i].second]) {
      ++vis[h[i].first];
      ++vis[h[i].second];
    }
  }
  int cnt = 0, ans = 1, mx = -1, c1 = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] > 1) cnt++;
    if (vis[i] == 1) c1++;
    if (vis[i] > mx) {
      mx = vis[i];
      ans = i;
    }
  }
  if (c1 > 2 && c1 != mx) cnt = 10;
  puts(cnt <= 1 ? "YES" : "NO");
  if (cnt <= 1) cout << ans << endl;
  return 0;
}
