#include <bits/stdc++.h>
using namespace std;
const int sz = 1e5 + 100;
vector<int> g[sz], c;
bool dfs(int v, int p) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != p)
      if (c[g[v][i]] != c[v] || !dfs(g[v][i], v)) return false;
  return true;
}
bool check(int v) {
  for (int i = 0; i < g[v].size(); i++)
    if (!dfs(g[v][i], v)) return false;
  return true;
}
int main() {
  int n, i, u, v, j;
  cin >> n;
  c.resize(n);
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < g[i].size(); j++)
      if (c[i] != c[g[i][j]]) {
        if (check(i)) {
          cout << "YES" << endl << i + 1;
          return 0;
        }
        if (check(g[i][j])) {
          cout << "YES" << endl << g[i][j] + 1;
          return 0;
        }
        cout << "NO";
        return 0;
      }
  cout << "YES" << endl << 1;
  return 0;
}
