#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, bool> dp;
bool rec(vector<vector<int>> &g, vector<int> &color, long long f, long long v) {
  long long key = v * g.size() + f;
  if (dp.count(key)) return dp[key];
  bool good = true;
  for (int j = 0; j < g[v].size(); ++j) {
    int newV = g[v][j];
    if (newV != f) {
      if (color[v] != color[newV]) {
        good = false;
      } else {
        good &= rec(g, color, v, newV);
      }
      if (!good) break;
    }
  }
  dp[key] = good;
  return good;
}
int main(int argc, const char *argv[]) {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int v1, v2;
    cin >> v1 >> v2;
    --v1;
    --v2;
    g[v1].push_back(v2);
    g[v2].push_back(v1);
  }
  vector<int> color(n);
  for (int i = 0; i < n; ++i) cin >> color[i];
  for (int i = 0; i < n; ++i) {
    bool good = true;
    for (int j = 0; j < g[i].size(); ++j) {
      int f = i;
      int v = g[i][j];
      bool r = rec(g, color, f, v);
      good &= r;
      if (!good) break;
    }
    if (good) {
      cout << "YES" << endl;
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
