#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
vector<int> edges[N];
vector<int> c(N);
bool good(int u, int p) {
  bool res = true;
  for (int v : edges[u]) {
    if (v != p) {
      if (c[u] != c[v]) {
        return false;
      }
      res &= good(v, u);
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int v0 = -1, v1 = -1;
  for (int i = 0; i < n; i++) {
    for (int node : edges[i]) {
      if (c[i] != c[node]) {
        v0 = i;
        v1 = node;
        break;
      }
    }
  }
  if (v0 == -1) {
    cout << "YES\n1\n";
    return 0;
  }
  bool got = true;
  int ans_node = -1;
  for (int v : edges[v0]) {
    got &= good(v, v0);
  }
  if (got) {
    ans_node = v0;
  }
  if (!got) {
    got = true;
    for (int v : edges[v1]) {
      got &= good(v, v1);
    }
    if (got) {
      cout << "YES\n" << v1 + 1 << '\n';
    } else {
      cout << "NO\n";
    }
  } else {
    cout << "YES\n" << ans_node + 1 << '\n';
  }
  return 0;
}
