#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100005];
int col[100005];
bool used[100005];
int finalnode[100005];
int par[100005];
int dfs(int u, int p) {
  used[u] = true;
  par[u] = p;
  int result = 0;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (used[v]) continue;
    result += dfs(v, u);
  }
  finalnode[u] = result;
  if (col[u] != col[p]) result++;
  return result;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) cin >> col[i];
  memset(used, 0, sizeof(used));
  ;
  int ans = dfs(1, 1) + 1;
  ans = -1;
  for (int i = 1; i <= n; i++) {
    int temp1 = finalnode[1] - finalnode[i], temp2 = 0;
    if (col[par[i]] != col[i]) temp1--;
    if (temp1 > 0) continue;
    for (int j = 0; j < edge[i].size(); j++) {
      int v = edge[i][j];
      if (v == par[i]) continue;
      temp2 += finalnode[v];
    }
    if (temp2 == 0) {
      ans = i;
      break;
    }
  }
  if (ans == -1) {
    cout << "NO";
  } else {
    cout << "YES" << endl;
    cout << ans << endl;
  }
  return 0;
}
