#include <bits/stdc++.h>
using namespace std;
const int N = (1e5);
vector<int> G[N + 5];
int n;
vector<int> C;
int M[N + 5];
bool vis[N + 5];
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < ((int)G[x].size()); i++) {
    int newvert = G[x][i];
    if (vis[newvert]) continue;
    if (C[newvert] != C[x]) {
      M[newvert]++;
      M[x]++;
    }
    dfs(newvert);
  }
}
int main() {
  cin >> n;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  C.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> C[i];
  dfs(1);
  vector<int> cero;
  vector<int> uno;
  vector<int> muchos;
  for (int i = 1; i <= n; i++) {
    if (M[i] == 0)
      cero.push_back(i);
    else if (M[i] == 1)
      uno.push_back(i);
    else
      muchos.push_back(i);
  }
  if (((int)muchos.size()) > 1) {
    cout << "NO" << endl;
  } else if (((int)muchos.size()) == 0) {
    if (((int)uno.size()) == 0) {
      cout << "YES" << endl << "1" << endl;
    } else if (((int)uno.size()) != 2)
      cout << "NO" << endl;
    else {
      cout << "YES" << endl << uno[0] << endl;
    }
  } else {
    if (((int)uno.size()) == M[muchos[0]])
      cout << "YES" << endl << muchos[0] << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
