#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int deg[N];
int n;
int u[N], v[N];
int c[N];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u[i] >> v[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  int need = 0;
  for (int i = 1; i < n; i++) {
    if (c[u[i]] != c[v[i]]) {
      need++;
      deg[u[i]]++;
      deg[v[i]]++;
    }
  }
  int root = -1;
  for (int i = 1; i <= n; i++) {
    if (deg[i] == need) {
      root = i;
      break;
    }
  }
  if (root == -1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    cout << root << endl;
  }
}
