#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
vector<int> adj[100010];
stack<int> s;
int c[100010];
bool used[100010];
int atka;
int atka2;
bool dfs(int source) {
  int i, v;
  used[source] = true;
  while (s.size() > 0) {
    v = s.top();
    s.pop();
    for (i = 0; i < adj[v].size(); i++) {
      if (adj[v][i] != source && c[v] != c[adj[v][i]]) {
        atka = v;
        atka2 = adj[v][i];
        return false;
      }
      if (!used[adj[v][i]]) {
        s.push(adj[v][i]);
        used[adj[v][i]] = true;
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i, n, x, y;
  bool flag;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (i = 1; i <= n; i++) cin >> c[i];
  memset(used, false, sizeof(used));
  used[1] = true;
  for (i = 0; i < adj[1].size(); i++) {
    int v = adj[1][i];
    used[v] = true;
    s.push(v);
  }
  flag = dfs(1);
  if (flag == true) {
    cout << "YES" << '\n';
    cout << 1 << '\n';
    return 0;
  }
  while (s.size() > 0) s.pop();
  memset(used, false, sizeof(used));
  used[atka] = true;
  for (i = 0; i < adj[atka].size(); i++) {
    int v = adj[atka][i];
    used[v] = true;
    s.push(v);
  }
  int temp = atka2;
  flag = dfs(atka);
  if (flag == true) {
    cout << "YES" << '\n';
    cout << atka << '\n';
    return 0;
  }
  while (s.size() > 0) s.pop();
  memset(used, false, sizeof(used));
  used[temp] = true;
  for (i = 0; i < adj[temp].size(); i++) {
    int v = adj[temp][i];
    used[v] = true;
    s.push(v);
  }
  flag = dfs(temp);
  if (flag == true) {
    cout << "YES" << '\n';
    cout << temp << '\n';
    return 0;
  }
  cout << "NO" << '\n';
  return 0;
}
