#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[100005];
set<long long int> adj2[100005];
set<long long int> s;
long long int col[100005];
set<long long int> se[100005];
long long int full, f, root;
int main() {
  map<long long int, long long int> mq;
  long long int n, i, j;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj2[u].insert(v);
    adj[v].push_back(u);
    adj2[v].insert(u);
  }
  for (i = 1; i <= n; i++) {
    cin >> col[i];
    s.insert(col[i]);
  }
  if (n == 2 || s.size() == 1) {
    cout << "YES"
         << "\n"
         << 1 << "\n";
    return 0;
  }
  if (n == 3) {
    cout << "YES"
         << "\n";
    for (i = 1; i <= 3; i++)
      if (adj[i].size() == 2) {
        cout << i << "\n";
        return 0;
      }
  }
  for (i = 1; i <= n; i++) {
    se[i].insert(col[i]);
    for (j = 0; j < adj[i].size(); j++) {
      se[i].insert(col[adj[i][j]]);
    }
  }
  for (i = 1; i <= n; i++) {
    if (se[i].size() == 1)
      full++;
    else if (se[i].size() == 2)
      mq[i] = 1;
    else if (se[i].size() <= 1 + adj[i].size()) {
      root = i;
      f++;
    }
  }
  if (f > 1) {
    cout << "NO"
         << "\n";
  } else if (full == n) {
    cout << "YES"
         << "\n"
         << 1 << "\n";
  } else {
    if (root == 0) {
      for (auto it : mq) {
        long long int cnt = 0;
        long long int k = it.first;
        for (i = 0; i < adj[k].size(); i++)
          if (mq.find(adj[k][i]) != mq.end()) cnt++;
        if (cnt == mq.size() - 1) {
          root = k;
          break;
        }
      }
    }
    if (root == 0)
      cout << "NO"
           << "\n";
    else
      cout << "YES"
           << "\n"
           << root << "\n";
  }
  return 0;
}
