#include <bits/stdc++.h>
using namespace std;
template <typename R, typename... Args>
std::function<R(Args...)> memo(R (*fn)(Args...)) {
  std::map<std::tuple<Args...>, R> table;
  return [fn, table](Args... args) mutable -> R {
    auto argt = std::make_tuple(args...);
    auto memoized = table.find(argt);
    if (memoized == table.end()) {
      auto result = fn(args...);
      table[argt] = result;
      return result;
    } else {
      return memoized->second;
    }
  };
}
int n;
vector<int> g[100001];
int c[100001];
bool um_rek(int elozo, int x);
auto rek = memo(um_rek);
bool um_rek(int elozo, int x) {
  for (int szomszed : g[x])
    if (szomszed != elozo) {
      if (c[x] != c[szomszed] || !rek(x, szomszed)) {
        return false;
      }
    }
  return true;
}
bool jo(int x) {
  for (int szomszed : g[x])
    if (!rek(x, szomszed)) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    if (jo(i)) {
      cout << "YES\n" << i << endl;
      return 0;
    }
  }
  cout << "NO\n" << flush;
}
