#include <bits/stdc++.h>
using namespace std;
const int nmax = 100005;
vector<int> l[nmax];
int c[nmax];
bool viz[nmax];
bool dfs(int x, int cul) {
  for (int i = 0; i < l[x].size(); i++)
    if (viz[l[x][i]] == 0)
      if (c[l[x][i]] == cul) {
        viz[l[x][i]] = 1;
        if (dfs(l[x][i], cul) == 0) return 0;
      } else
        return 0;
  return 1;
}
int main() {
  int n, u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    l[u].push_back(v);
    l[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) cin >> c[i];
  int n1 = -1, n2 = -1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < l[i].size(); j++)
      if (c[i] != c[l[i][j]]) {
        n1 = i;
        n2 = l[i][j];
        break;
      }
  if (n1 == -1 and n2 == -1) {
    cout << "YES\n1";
    return 0;
  }
  viz[n1] = 1;
  bool ok = true;
  for (int i = 0; i < l[n1].size(); i++)
    if (dfs(l[n1][i], c[l[n1][i]]) == 0) {
      ok = false;
      break;
    }
  if (ok == true) {
    cout << "YES\n";
    cout << n1;
    return 0;
  }
  memset(viz, 0, sizeof(viz));
  viz[n2] = 1;
  ok = true;
  for (int i = 0; i < l[n2].size(); i++)
    if (dfs(l[n2][i], c[l[n2][i]]) == 0) {
      ok = false;
      break;
    }
  if (ok == true) {
    cout << "YES\n";
    cout << n2;
    return 0;
  }
  cout << "NO";
  return 0;
}
