#include <bits/stdc++.h>
using namespace std;
vector<int> v[100009];
int c[100009];
int n;
void check(int x, bool first[], set<int> &second) {
  first[x] = 1;
  for (auto it : v[x]) {
    if (!first[it]) {
      check(it, first, second);
    }
  }
  second.insert(c[x]);
}
void input() {
  cin >> n;
  int a1 = -1, b1 = -1;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (auto it : v[i]) {
      if (c[i] != c[it]) {
        a1 = i;
        b1 = it;
        break;
      }
    }
    if (a1 != -1 || b1 != -1) {
      break;
    }
  }
  if (a1 == -1) {
    cout << "YES\n";
    cout << 1 << "\n";
    return;
  }
  int f1 = 0;
  for (auto it : v[a1]) {
    bool first[n + 1];
    memset(first, 0, sizeof(first));
    first[a1] = 1;
    set<int> second;
    check(it, first, second);
    if (second.size() > 1) {
      f1 = 1;
      break;
    }
  }
  if (f1 == 0) {
    cout << "YES\n";
    cout << a1 << "\n";
    return;
  }
  f1 = 0;
  for (auto it : v[b1]) {
    bool first[n + 1];
    memset(first, 0, sizeof(first));
    first[b1] = 1;
    set<int> second;
    check(it, first, second);
    if (second.size() > 1) {
      f1 = 1;
      break;
    }
  }
  if (f1 == 0) {
    cout << "YES\n";
    cout << b1 << "\n";
    return;
  }
  cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  return 0;
}
