#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int a[100005];
bool dfs(int node, int par) {
  bool ans = 1;
  for (int i : g[node]) {
    if (i == par) continue;
    if (a[i] != a[node]) {
      return false;
    }
    ans &= dfs(i, node);
  }
  return ans;
}
int i, j;
int main() {
  int n;
  cin >> n;
  for (i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int k1, k2 = k1 = 0;
  for (i = 1; i <= n; i++) {
    for (int j : g[i]) {
      if (a[i] != a[j]) {
        k1 = i, k2 = j;
        break;
      }
    }
  }
  if (!k1) {
    cout << "YES" << '\n' << 1 << '\n';
    return 0;
  }
  bool flag = true;
  for (int i : g[k1]) {
    flag &= dfs(i, k1);
  }
  if (flag) {
    cout << "YES" << '\n' << k1 << '\n';
    return 0;
  }
  flag = true;
  for (int i : g[k2]) {
    flag &= dfs(i, k2);
  }
  if (flag)
    cout << "YES" << '\n' << k2 << '\n';
  else
    cout << "NO" << '\n';
}
