#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> v(100005);
vector<pair<long long int, long long int>> vp;
long long int visited[100005] = {0}, color, c[100005] = {0}, f = 0;
void dfs(long long int x) {
  long long int i, j, k, l;
  visited[x] = 1;
  for (i = 0; i < v[x].size(); i++) {
    if (f == 1) {
      return;
    }
    if (visited[v[x][i]] == 0 && c[v[x][i]] == color) {
      visited[v[x][i]] = 1;
      dfs(v[x][i]);
    } else if (visited[v[x][i]] == 0 && c[v[x][i]] != color) {
      f = 1;
      return;
    }
  }
}
int main() {
  long long int n, i, j, k, l;
  cin >> n;
  long long int a, b;
  for (i = 0; i < n - 1; i++) {
    cin >> a >> b;
    vp.push_back({a, b});
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (i = 0; i < n - 1; i++) {
    if (c[vp[i].first] != c[vp[i].second]) {
      memset(visited, 0, sizeof(visited));
      visited[vp[i].first] = 1;
      for (j = 0; j < v[vp[i].first].size(); j++) {
        color = c[v[vp[i].first][j]];
        dfs(v[vp[i].first][j]);
        if (f == 1) {
          break;
        }
      }
      if (f == 0) {
        cout << "YES" << endl << vp[i].first;
        return 0;
      } else {
        f = 0;
        memset(visited, 0, sizeof(visited));
        visited[vp[i].second] = 1;
        for (j = 0; j < v[vp[i].second].size(); j++) {
          color = c[v[vp[i].second][j]];
          dfs(v[vp[i].second][j]);
          if (f == 1) {
            break;
          }
        }
        if (f == 0) {
          cout << "YES" << endl << vp[i].second;
          return 0;
        } else {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES" << endl << 1;
}
