#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 7;
long long int in[N] = {}, out[N] = {}, arr[N] = {}, in1[N] = {}, out1[N] = {};
long long int h[N] = {};
vector<long long int> v[N];
void dfs(long long int u, long long int p) {
  for (long long int child : v[u]) {
    if (child == p) continue;
    dfs(child, u);
    if (arr[child] == arr[u]) {
      long long int x = in[child];
      if (x == 0) {
        in[u] = 0;
        h[u]++;
      } else
        in[u] = ((in[u]) & (x));
    } else {
      in[u] = 0;
      h[u]++;
    }
    in1[u] = ((in1[u]) & (in[child]));
  }
}
void dfs1(long long int u, long long int p) {
  for (long long int child : v[u]) {
    if (child == p) continue;
    if (h[u] >= 2)
      out[child] = 0;
    else if (h[u] == 0)
      out[child] = out1[u];
    else {
      if ((in[child] == 1) && (arr[child] == arr[u]))
        out[child] = 0;
      else
        out[child] = out1[u];
    }
    out1[child] = ((arr[u] == arr[child]) & (out[child]));
    dfs1(child, u);
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    for (long long int i = 0; i < n - 1; i++) {
      long long int a, b;
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    long long int c = 0;
    for (long long int i = 1; i <= n; i++) {
      cin >> arr[i];
    }
    for (long long int i = 0; i < N; i++) {
      in[i] = 1;
      out[i] = 1;
      in1[i] = 1;
      out1[i] = 1;
      h[i] = 0;
    }
    dfs(1, 0);
    dfs1(1, 0);
    long long int flag = 0;
    for (long long int i = 1; i <= n; i++) {
      if ((in1[i] == 1) && (out[i] == 1)) {
        flag = 1;
        cout << "YES" << endl;
        cout << i << endl;
        break;
      }
    }
    if (flag == 1) continue;
    cout << "NO" << endl;
  }
}
