#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x, y;
  y = scanf("%d", &x);
  return x;
}
const int N = 1e5 + 123;
int c[N], pc, cc;
vector<int> v[N];
bool dfs(int x, int p, int rt) {
  if (p != -1 && c[x] != c[p] && p != rt) {
    pc = p;
    cc = x;
    return false;
  }
  for (auto u : v[x])
    if (u != p)
      if (dfs(u, x, rt) == false) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  for (int i = 0; i < (n); i++) cin >> c[i];
  if (dfs(0, -1, 0) == false) {
    int o = cc, k = pc;
    if (dfs(o, -1, o) == false) {
      int k = pc;
      if (dfs(k, -1, k) == false)
        cout << "NO" << endl;
      else
        cout << "YES\n" << k + 1 << endl;
    } else
      cout << "YES\n" << o + 1 << endl;
  } else
    cout << "YES\n" << 1 << endl;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
