#include <bits/stdc++.h>
using namespace std;
int color[100009];
int vis[100009];
map<int, vector<int> > v;
long long n, m, ans = 0, x, y, mn = 1e16, mx = 0;
int bfs(int s) {
  int par[100009];
  queue<int> q;
  par[s] = s;
  q.push(s);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (vis[cur]) continue;
    vis[cur] = 1;
    if (par[cur] == s)
      s = s;
    else if (color[cur] != color[par[cur]])
      return 0;
    for (int i = 0; i < v[cur].size(); i++) {
      if (vis[v[cur][i]]) continue;
      q.push(v[cur][i]);
      par[v[cur][i]] = cur;
    }
  }
  return 5;
}
int main() {
  cin >> n;
  vector<pair<int, int> > vec;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    v[--x].push_back(--y);
    v[y].push_back(x);
    vec.push_back({x, y});
  }
  for (int i = 0; i < n; i++) {
    cin >> color[i];
  }
  for (int i = 0; i < vec.size(); i++) {
    if (color[vec[i].first] == color[vec[i].second]) continue;
    ans++;
    memset(vis, 0, sizeof vis);
    if (bfs(vec[i].second))
      return cout << "YES\n" << vec[i].second + 1 << endl, 0;
    memset(vis, 0, sizeof vis);
    if (bfs(vec[i].first))
      return cout << "YES\n" << vec[i].first + 1 << endl, 0;
    break;
  }
  if (!ans)
    cout << "YES\n" << 1;
  else
    cout << "NO" << endl;
  return 0;
}
