#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<long long, long long> > vect;
  long long n, u, v, col[200010];
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    vect.push_back(make_pair(u, v));
  }
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
  }
  bool flag = false;
  long long a = -1, b = -1, com = -1;
  for (int i = 1; i <= n - 1; i++) {
    u = vect[i - 1].first;
    v = vect[i - 1].second;
    if (col[u] != col[v]) {
      if (a == -1 && b == -1) {
        a = u;
        b = v;
      } else if (flag == false) {
        if (u == a || v == a) {
          com = a;
        } else if (u == b || v == b) {
          com = b;
        } else {
          cout << "NO" << endl;
          return 0;
        }
        flag = true;
      } else {
        if (u != com && v != com) {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
  cout << "YES" << endl;
  if (flag == false)
    cout << max(a, 1ll) << endl;
  else {
    cout << com << endl;
  }
  return 0;
}
