#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = 3.141592653589793238462;
vector<vector<int> > adjList;
map<int, bool> vis;
vector<pair<int, int> > r;
int c[100005];
void dfs(int src, int col, int root, bool &ok) {
  vis[src] = true;
  for (auto &u : adjList[src]) {
    if (c[u] != col && u != root) {
      ok = false;
      return;
    }
    if (!vis[u]) dfs(u, col, root, ok);
  }
}
bool check(int s) {
  vis.clear();
  vis[s] = true;
  for (auto &u : adjList[s]) {
    bool ok = true;
    dfs(u, c[u], s, ok);
    if (!ok) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  adjList.resize(n);
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--, v--;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    r.push_back(make_pair(u, v));
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int p = -1, q = -1;
  for (int i = 0; i < r.size(); i++) {
    if (c[r[i].first] != c[r[i].second]) {
      p = r[i].first;
      q = r[i].second;
      break;
    }
  }
  if (p == -1) {
    cout << "YES\n" << 1 << '\n';
    return 0;
  }
  if (check(p)) {
    cout << "YES\n" << p + 1 << '\n';
  } else if (check(q)) {
    cout << "YES\n" << q + 1 << '\n';
  } else {
    cout << "NO\n";
  }
  return 0;
}
