#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
vector<int> adj[MAXN];
int col[MAXN], colTree[MAXN];
int color(int u, int p) {
  for (int i = 0; i < int(((int)(adj[u]).size())); i++) {
    int v = adj[u][i];
    if (v != p) color(v, u);
  }
  int c = col[u];
  for (int i = 0; i < int(((int)(adj[u]).size())); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (colTree[v] != c) return colTree[u] = -1;
  }
  return colTree[u] = c;
}
int solve(int u, int p, int colUp) {
  int c = 0, dif = -1;
  for (int i = 0; i < int(((int)(adj[u]).size())); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    int colv = colTree[v];
    if (colv == -1) {
      if (dif == -1)
        dif = v;
      else
        return -1;
    } else {
      if (c == 0)
        c = colv;
      else if (c != colv)
        c = -1;
    }
  }
  if (dif != -1) {
    if (colUp == col[u] && (c == 0 || c == colUp))
      return solve(dif, u, colUp);
    else
      return -1;
  } else
    return u;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < int(n - 1); i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int u = 0; u < int(n); u++) cin >> col[u];
  color(0, -1);
  int sol = solve(0, -1, col[0]);
  if (sol == -1)
    cout << "NO" << '\n';
  else
    cout << "YES" << '\n' << sol + 1 << '\n';
  return 0;
}
