#include <bits/stdc++.h>
using namespace std;
template <class A>
void read(vector<A>& v);
template <class A, size_t S>
void read(array<A, S>& a);
template <class T>
void read(T& x) {
  cin >> x;
}
void read(double& d) {
  string t;
  read(t);
  d = stod(t);
}
void read(long double& d) {
  string t;
  read(t);
  d = stold(t);
}
template <class H, class... T>
void read(H& h, T&... t) {
  read(h);
  read(t...);
}
template <class A>
void read(vector<A>& x) {
  for (auto& a : x) read(a);
}
template <class A, size_t S>
void read(array<A, S>& x) {
  for (auto& a : x) read(a);
}
const int mod = 1e9 + 7;
long long int primeLimit = 1e5;
const double PI = acos(-1);
bool prime[100000];
string LongestPalindromicPrefix(string str) {
  string temp = str + '?';
  reverse(str.begin(), str.end());
  temp += str;
  long long int n = temp.length();
  long long int lps[n];
  fill(lps, lps + n, 0);
  for (long long int i = 1; i < n; i++) {
    long long int len = lps[i - 1];
    while (len > 0 && temp[len] != temp[i]) {
      len = lps[len - 1];
    }
    if (temp[i] == temp[len]) {
      len++;
    }
    lps[i] = len;
  }
  return temp.substr(0, lps[n - 1]);
}
bool binarySearchFloat(float lower, float higher, float maxErrorAllowed,
                       long long int numberOfTimesWanttoRunCode) {
  float l = lower, r = higher;
  float eps = maxErrorAllowed;
  long long int iteration_count = numberOfTimesWanttoRunCode;
  for (long long int i = 0; i < iteration_count && l + eps < r; ++i) {
  }
}
void primefinder() {
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  prime[0] = false;
  for (long long int i = 2; i < primeLimit; i++) {
    if (prime[i]) {
      for (long long int j = i * i; j < primeLimit; j += i) {
        prime[j] = false;
      }
    }
  }
}
long long fast_pow(long long int x, long long int y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long Fast_pow(long long int x, long long int y, long long int p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
unordered_map<long long int, vector<long long int>> mp;
bool ans = false;
vector<long long int> col;
unordered_set<long long int> visited;
long long int node = 0;
long long int pr = -1;
long long int dfs(long long int i) {
  if (visited.find(i) != visited.end()) return -1;
  visited.insert(i);
  set<long long int> s;
  bool is = true;
  for (long long int j = 0; j < mp[i].size(); j++) {
    if (mp[i][j] == node) continue;
    if (visited.find(mp[i][j]) == visited.end()) {
      is = false;
      long long int get = dfs(mp[i][j]);
      if (get != -1) {
        s.insert(get);
      }
    }
  }
  if (is) {
    return col[i];
  } else {
    s.insert(col[i]);
    if (s.size() > 1) {
      node = i;
      if (pr == node) return -1;
      ans = true;
    } else {
      return col[i];
    }
    return -1;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    mp[a].push_back(b);
    mp[b].push_back(a);
  }
  col.resize(n + 1);
  for (long long int i = 1; i <= n; i++) {
    cin >> col[i];
  }
  dfs(1);
  if (ans == false) {
    cout << "YES\n";
    cout << "1\n";
    return 0;
  }
  pr = node;
  node = 0;
  ans = false;
  visited.clear();
  dfs(1);
  if (ans == false) {
    cout << "YES\n";
    cout << node;
    return 0;
  }
  cout << "NO\n";
}
