#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<int> c;
vector<vector<int> > g;
int x = -1, y = -1;
bool check(int s, vector<int>& v, int col) {
  v[s] = 1;
  if (col != c[s]) return false;
  for (int i = (0); i < (int((g[s]).size())); ++i) {
    if (!v[g[s][i]])
      if (!check(g[s][i], v, col)) return false;
  }
  return true;
}
int main() {
  (ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0));
  int n, u, v;
  cin >> n;
  c.resize(n);
  g.resize(n);
  for (int i = (0); i < (n - 1); ++i) {
    cin >> u >> v;
    v--, u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = (0); i < (n); ++i) cin >> c[i];
  vector<int> vis(n, 0);
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (int((g[i]).size())); ++j) {
      if (c[g[i][j]] != c[i]) {
        x = i;
        y = g[i][j];
        break;
      }
    }
    if (x != -1) break;
  }
  bool status = true;
  if (x == -1) {
    cout << "YES\n";
    cout << 1;
    return 0;
  }
  vis[x] = 1;
  for (int i = (0); i < (int((g[x]).size())); ++i) {
    status &= check(g[x][i], vis, c[g[x][i]]);
  }
  if (status) {
    cout << "YES\n";
    cout << x + 1;
    return 0;
  }
  for (int i = (0); i < (n); ++i) vis[i] = 0;
  status = true;
  vis[y] = 1;
  for (int i = (0); i < (int((g[y]).size())); ++i) {
    status &= check(g[y][i], vis, c[g[y][i]]);
  }
  if (status) {
    cout << "YES\n";
    cout << y + 1;
    return 0;
  }
  cout << "NO";
}
