#include <bits/stdc++.h>
using namespace std;
long long int recpow(long long int x, long long int n, long long int mod) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return recpow((x * x) % mod, n / 2, mod);
  else
    return (x * recpow((x * x) % mod, (n - 1) / 2, mod)) % mod;
}
bool sortbysec(
    const pair<pair<long long int, long long int>, long long int> &a,
    const pair<pair<long long int, long long int>, long long int> &b) {
  if (a.second == b.second)
    return (a.first.second < b.first.second);
  else
    return (a.second > b.second);
}
long long int modInverse(long long int n, long long int p) {
  return recpow(n, p - 2, p);
}
long long int nCr(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
const int N = 15000001;
int sp[N + 1];
vector<int> pr;
void sieve() {
  for (long long int i = 2; i < N + 1; i++) {
    if (sp[i] == 0) {
      sp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= sp[i] && i * pr[j] <= N; ++j)
      sp[i * pr[j]] = pr[j];
  }
}
vector<long long int> pf(long long int n) {
  long long int no = n;
  vector<long long int> v;
  while (no != 1) {
    long long int h = sp[no];
    v.push_back(h);
    no /= h;
  }
  return v;
}
string rev(string s) {
  string t;
  for (long long int i = s.length() - 1; i >= 0; i--) {
    t.push_back(s[i]);
  }
  return t;
}
bool is_p(long long int n) {
  for (long long int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
bool ispow2(long long int n) {
  while (n % 2 == 0) n /= 2;
  if (n == 1) return true;
  return false;
}
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  return (a.first >= b.first and a.second >= b.second);
}
string itos(long long int n) {
  string s = "";
  if (n == 0) return "0";
  while (n > 0) {
    s.push_back(n % 10 + '0');
    n /= 10;
  }
  s = rev(s);
  return s;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> edges;
  long long int c[n + 1];
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    edges.push_back({x, y});
  }
  for (long long int i = 1; i < n + 1; i++) cin >> c[i];
  map<long long int, long long int> mp;
  long long int cnt = 0;
  for (long long int i = 0; i < edges.size(); i++) {
    if (c[edges[i].first] == c[edges[i].second]) continue;
    cnt++;
    mp[edges[i].first]++;
    mp[edges[i].second]++;
  }
  for (auto it : mp) {
    if (it.second == cnt) {
      cout << "YES\n";
      cout << it.first << "\n";
      return 0;
    }
  }
  if (cnt == 0) {
    cout << "YES\n";
    cout << 1 << "\n";
    return 0;
  }
  cout << "NO\n";
  return 0;
}
