#include <bits/stdc++.h>
using namespace std;
vector<long long int> graph[100001];
long long int color[100001] = {0};
long long int ok = 1;
void dfs(long long int u, long long int p, long long int root) {
  for (auto i : graph[u]) {
    if (i != p) {
      if (u != root) {
        if (color[u] != color[i]) {
          ok = 0;
          return;
        }
      }
      dfs(i, u, root);
    }
  }
}
int main() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> edges;
  for (long long int i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
    edges.push_back({u, v});
  }
  for (long long int i = 1; i <= n; i++) {
    cin >> color[i];
  }
  long long int u = 0, v = 0;
  for (auto i : edges) {
    if (color[i.first] != color[i.second]) {
      u = i.first;
      v = i.second;
      break;
    }
  }
  if (!u || !v) {
    cout << "YES" << endl << 1 << endl;
  } else {
    ok = 1;
    dfs(u, u, u);
    if (ok) {
      cout << "YES" << endl << u << endl;
      return 0;
    }
    ok = 1;
    dfs(v, v, v);
    if (ok) {
      cout << "YES" << endl << v << endl;
      return 0;
    }
    cout << "NO" << endl;
  }
  return 0;
}
