#include <bits/stdc++.h>
using namespace std;
typedef struct stu {
  int val;
  struct stu* next;
} node;
node* head[100005];
int visit[100005] = {0}, c[100005], mini = 100002, maxi = 0, s[100005], top = 1,
    leaf[100005] = {0}, ans = -1, fina = 0, fuc = 0;
void insert(int a, int b) {
  node* t;
  t = new node;
  t->val = b;
  t->next = head[a];
  head[a] = t;
}
void dfs(int i, int first) {
  visit[i] = 1;
  node* t;
  t = head[i];
  while (t != NULL) {
    if (visit[t->val] == 0) {
      dfs(t->val, first);
      if (i != first && c[t->val] != c[i]) {
        fuc = 1;
      }
    }
    t = t->next;
  }
}
int main() {
  int i, n, u, v, flag[100005] = {0}, arr[100002], len = 0, edge[100005][2];
  for (i = 0; i < 100005; i++) head[i] = NULL;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> edge[i][0] >> edge[i][1];
    insert(edge[i][0], edge[i][1]);
    insert(edge[i][1], edge[i][0]);
  }
  for (i = 1; i <= n; i++) {
    cin >> c[i];
    flag[c[i]]++;
  }
  for (i = 0; i < n - 1; i++) {
    if (c[edge[i][0]] != c[edge[i][1]]) {
      break;
    }
  }
  if (i != n - 1) {
    ans = -1;
    int h;
    h = edge[i][0];
    dfs(h, h);
    if (fuc == 0) {
      ans = h;
    }
    h = edge[i][1];
    for (i = 0; i < 100005; i++) visit[i] = 0;
    if (fuc == 1) {
      fuc = 0;
      dfs(h, h);
      if (fuc == 0) ans = h;
    }
    if (n > 2 && ans == -1) {
      cout << "NO\n";
    } else {
      if (n == 2) ans = 1;
      cout << "YES\n";
      cout << ans << endl;
    }
  } else {
    cout << "YES\n";
    cout << "1" << endl;
  }
  return 0;
}
