#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[100005];
long long a[100005];
long long col;
bool ok;
bool dfs(long long v, long long par) {
  ok &= (col == a[v]);
  for (auto i : adj[v]) {
    if (i != par) dfs(i, v);
  }
}
bool fn(long long v) {
  bool res = 1;
  for (auto i : adj[v]) {
    ok = 1;
    col = a[i];
    dfs(i, v);
    res &= ok;
  }
  return res;
}
int main() {
  int t = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  while (t--) {
    long long n;
    cin >> n;
    long long i;
    long long p = -1, q = -1;
    for (i = 1; i < n; i++) {
      long long x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    for (i = 0; i < n; i++) cin >> a[i + 1];
    for (i = 1; i <= n; i++) {
      for (auto j : adj[i]) {
        if (a[j] != a[i]) {
          p = i;
          q = j;
        }
      }
    }
    if (q == -1) {
      cout << "YES" << endl;
      cout << 1 << endl;
      continue;
    }
    bool a1 = fn(p);
    bool a2 = fn(q);
    if (a1) {
      cout << "YES" << endl;
      cout << p << endl;
    } else if (a2) {
      cout << "YES" << endl;
      cout << q << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
