#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int N = 100010;
vector<int> g[N];
int n, curr_color, color[N];
bool ok;
bool dfs(int v, int parent) {
  ok = ok && (color[v] == curr_color);
  for (int i = 0; i < (int)(g[v].size()); i++) {
    if (g[v][i] != parent) dfs(g[v][i], v);
  }
}
bool solve(int v) {
  int ans = true;
  for (int i = 0; i < (int)(g[v].size()); i++) {
    curr_color = color[g[v][i]];
    ok = true;
    dfs(g[v][i], v);
    ans = ans && ok;
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n - 1); i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < (int)(n); i++) cin >> color[i + 1];
  int root1 = -1, root2 = -1;
  for (int i = (int)(1); i < (int)(n + 1); ++i) {
    for (auto elem : g[i]) {
      if (color[elem] != color[i]) {
        root1 = elem;
        root2 = i;
      }
    }
  }
  if (root1 == -1) {
    cout << "YES\n1";
    return 0;
  }
  bool res1 = solve(root1);
  bool res2 = solve(root2);
  if (res1)
    cout << "YES\n" << root1;
  else if (res2)
    cout << "YES\n" << root2;
  else
    cout << "NO";
  return 0;
}
