#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> adj[N];
bool vis[N];
vector<pair<long long, long long> > edges;
int n;
int c[N];
int a, b;
int r1, r2;
bool unvisit() {
  for (int i = 0; i < N; i++) {
    vis[i] = false;
  }
  return true;
}
bool dfs(int r, int col) {
  bool ans = true;
  vis[r] = true;
  if (c[r] != col) return false;
  for (int i = 0; i < adj[r].size(); i++) {
    if (vis[adj[r][i]]) continue;
    ans &= dfs(adj[r][i], col);
  }
  return ans;
}
bool check(int r) {
  vis[r] = true;
  bool ans = true;
  for (int i = 0; i < adj[r].size(); i++) {
    ans &= dfs(adj[r][i], c[adj[r][i]]);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    edges.push_back(make_pair(a, b));
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  r1 = r2 = -1;
  for (int i = 0; i < n - 1; i++) {
    if (c[edges[i].first] == c[edges[i].second]) continue;
    r1 = edges[i].first;
    r2 = edges[i].second;
    break;
  }
  if (r1 == -1) {
    cout << "YES" << endl << 1 << endl;
  } else {
    if (check(r1)) {
      cout << "YES" << endl << r1 << endl;
    } else if (unvisit() && check(r2)) {
      cout << "YES" << endl << r2 << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
