#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& _p) {
  return os << "(" << _p.first << "," << _p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& _V) {
  bool f = true;
  os << "[";
  for (auto v : _V) {
    os << (f ? "" : ",") << v;
    f = false;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& _S) {
  bool f = true;
  os << "(";
  for (auto s : _S) {
    os << (f ? "" : ",") << s;
    f = false;
  }
  return os << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& _M) {
  return os << set<pair<T, U>>(_M.begin(), _M.end());
}
const signed long long INF = 1000000100;
const long double EPS = 1e-9;
void read_data() {}
void solve() {}
vector<int> V[100100];
int O[100100];
int C[100100];
int prz;
int T;
int dfs(int u, int a) {
  O[u] = T;
  set<int> mc;
  for (int v : V[u]) {
    if (O[v] == T) continue;
    mc.insert(dfs(v, 0));
  }
  if (a == 0) {
    mc.insert(C[u]);
    if (mc.size() != 1) return -1;
    return C[u];
  }
  if (mc.find(-1) == mc.end()) {
    cout << "YES\n" << u << endl;
    exit(0);
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> E;
  for (int(i) = (1); (i) < (n); (i)++) {
    int a, b;
    scanf("%d%d", &a, &b);
    E.push_back(make_pair(a, b));
    V[a].push_back(b);
    V[b].push_back(a);
  }
  pair<int, int> gm = make_pair(-1, -1);
  for (int(i) = (1); (i) <= (n); (i)++) scanf("%d", &C[i]);
  for (auto e : E)
    if (C[e.first] != C[e.second]) gm = e;
  if (gm == make_pair(-1, -1)) {
    cout << "YES\n1\n";
    return 0;
  }
  T = 1;
  dfs(gm.first, 1);
  T = 2;
  dfs(gm.second, 1);
  cout << "NO\n";
}
