#include <bits/stdc++.h>
using namespace std;
int n, curr_color, c[1000000];
bool ok;
vector<int> a[1000000];
void dfs(int v, int parent) {
  ok = ok & (c[v] == curr_color);
  for (int i = 0; i < a[v].size(); ++i)
    if (a[v][i] != parent) dfs(a[v][i], v);
}
bool can(int v) {
  for (int i = 0; i < a[v].size(); ++i) {
    curr_color = c[a[v][i]];
    ok = true;
    dfs(a[v][i], v);
    if (!ok) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) cin >> c[i];
  int root1 = -1, root2 = -1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < a[i].size(); ++j)
      if (c[i] != c[a[i][j]]) {
        root1 = i;
        root2 = a[i][j];
      }
  if (root1 == -1)
    cout << "YES\n" << 1;
  else if (can(root1))
    cout << "YES\n" << root1;
  else if (can(root2))
    cout << "YES\n" << root2;
  else
    cout << "NO";
}
