#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > adj(100001);
long long int colors[100001] = {0};
long long int visited[100001] = {0};
long long int dp[100001] = {0};
void DFS(long long int u, long long int color, bool& res,
         long long int source) {
  visited[u] = 1;
  for (long long int i = 0; i < adj[u].size(); i++) {
    if (adj[u][i] != source && colors[adj[u][i]] == color) {
      DFS(adj[u][i], color, res, u);
    } else if (adj[u][i] != source && colors[adj[u][i]] != color) {
      res = false;
      return;
    }
  }
}
void DFS2(long long int u, bool& res) {
  for (long long int i = 0; i < adj[u].size(); i++) {
    long long int color = colors[adj[u][i]];
    bool ok = true;
    DFS(adj[u][i], color, ok, u);
    res = res && ok;
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(10);
  cout << fixed;
  ;
  clock_t begin = clock();
  long long int n;
  cin >> n;
  long long int u_x = -1;
  long long int u_y = -1;
  for (long long int i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (long long int i = 0; i < n; i++) {
    cin >> colors[i];
  }
  bool found = false;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < adj[i].size(); j++) {
      if (colors[i] != colors[adj[i][j]]) {
        u_x = i;
        u_y = adj[i][j];
      }
    }
  }
  if (u_x == -1 && u_y == -1) {
    cout << "YES" << endl;
    cout << 1 << endl;
    return 0;
  }
  bool done1 = true;
  bool done2 = true;
  DFS2(u_x, done1);
  memset(visited, 0, sizeof(visited));
  DFS2(u_y, done2);
  if (done1) {
    cout << "YES" << endl;
    cout << u_x + 1 << endl;
    return 0;
  } else if (done2) {
    cout << "YES" << endl;
    cout << u_y + 1 << endl;
    return 0;
  }
  cout << "NO" << endl;
  clock_t end = clock();
  cerr << "Time elapsed: " << double(end - begin) / CLOCKS_PER_SEC << "secs"
       << endl;
  return 0;
}
