#include <bits/stdc++.h>
using namespace std;
const int sz = 1000000;
int main() {
  vector<vector<int> > g;
  int n, col[sz], count[sz];
  queue<int> q;
  scanf("%d", &n);
  g.resize(n);
  for (int i = 0; i < n; ++i) g[i].clear();
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &col[i]);
  }
  for (int i = 0; i < n; ++i) count[i] = -1;
  for (int i = 0; i < n; ++i)
    if (count[i] == -1) {
      int cnt = 0;
      q.push(i);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        if (count[v] == -1 && col[v] == col[i]) {
          count[v] = 0;
          cnt++;
          for (int k = 0; k < g[v].size(); k++) q.push(g[v][k]);
        }
      }
      q.push(i);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        if (count[v] == 0 && col[v] == col[i]) {
          count[v] = cnt;
          for (int k = 0; k < g[v].size(); k++) q.push(g[v][k]);
        }
      }
    }
  bool yes = false;
  int x = 0;
  for (int i = 0; i < n; ++i) {
    int sum = count[i] - 1;
    for (int j = 0; j < g[i].size(); j++)
      if (col[g[i][j]] != col[i]) sum += count[g[i][j]];
    if (sum == n - 1) {
      yes = true;
      x = i;
    }
  }
  if (yes)
    printf("YES\n%d\n", x + 1);
  else
    printf("NO\n");
}
