#include <bits/stdc++.h>
using namespace std;
vector<long int> vec[100001];
vector<pair<long int, long int> > edge;
long int col[100001] = {0};
long int cnt = 0;
long int vis[100001] = {0};
void dfs(long int ind, long int colre = -1) {
  vis[ind] = 1;
  if (colre == -1) {
    for (auto it : vec[ind]) {
      if (vis[it] == 0) {
        cnt++;
        vis[it] = 1;
        dfs(it, col[it]);
      }
    }
  } else {
    for (auto it : vec[ind]) {
      if (vis[it] == 0) {
        vis[it] = 1;
        if (col[it] == colre) {
          cnt++;
          dfs(it, colre);
        } else {
          cnt = -1;
          return;
        }
      }
    }
  }
}
int main() {
  long int i, j, k, l, n, test_case, a, b;
  test_case = 1;
  while (test_case--) {
    cin >> n;
    for (i = 0; i < n - 1; i++) {
      cin >> a >> b;
      vec[a - 1].push_back(b - 1);
      vec[b - 1].push_back(a - 1);
      edge.push_back(make_pair(a - 1, b - 1));
    }
    for (i = 0; i < n; i++) {
      cin >> col[i];
    }
    for (auto &it : edge) {
      if (col[it.first] != col[it.second]) {
        vis[it.first] = 1;
        dfs(it.first);
        if (cnt == n - 1) {
          cout << "YES\n";
          cout << it.first + 1;
          return 0;
        }
        memset(vis, 0, sizeof vis);
        cnt = 0;
        vis[it.second] = 1;
        dfs(it.second);
        if (cnt == n - 1) {
          cout << "YES\n";
          cout << it.second + 1;
          return 0;
        }
        cout << "NO";
        return 0;
      }
    }
    cout << "YES\n";
    cout << 1;
  }
  return 0;
}
