#include <bits/stdc++.h>
using namespace std;
const long long MOD9 = 1e9 + 7;
const long long MAX = 2e5 + 10;
const double eps = 0.99;
int t, n, m, x, y;
int a[MAX];
vector<vector<int> > G;
vector<bool> vis;
vector<int> col;
set<int> s;
vector<pair<int, int> > in;
int main() {
  cin >> n;
  G.resize(n);
  vis.resize(n);
  col.resize(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    x--;
    y--;
    in.push_back(make_pair(x, y));
  }
  set<int> cc;
  for (int i = 0; i < n; i++) {
    cin >> x;
    col[i] = x;
    cc.insert(x);
  }
  if (cc.size() == 1) {
    cout << "YES\n" << in[0].first + 1;
  } else {
    for (int i = 0; i < in.size(); i++) {
      if (col[in[i].first] != col[in[i].second]) {
        G[in[i].first].push_back(in[i].second);
        G[in[i].second].push_back(in[i].first);
        s.insert(in[i].second);
        s.insert(in[i].first);
      }
    }
    for (auto x : s) {
      if (G[x].size() == s.size() - 1) {
        cout << "YES\n" << x + 1;
        return 0;
      }
    }
    cout << "NO";
  }
}
