#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
pair<int, int> p[100010];
int mi;
int a[100010];
void dfs(int sr, int col, int par) {
  for (int i = 0; i < v[sr].size(); i++) {
    if (v[sr][i] != par) {
      if (col == a[v[sr][i] - 1]) {
        dfs(v[sr][i], col, sr);
      } else {
        mi = 0;
        return;
      }
    }
  }
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
    p[i].first = x;
    p[i].second = y;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int f = -1;
  for (int i = 0; i < n - 1; i++) {
    if (a[p[i].first - 1] != a[p[i].second - 1]) {
      f = i;
      break;
    }
  }
  if (f == -1) {
    printf("YES\n");
    printf("1\n");
    return 0;
  }
  mi = 1;
  for (int i = 0; i < (int)v[p[f].first].size(); i++) {
    dfs(v[p[f].first][i], a[v[p[f].first][i] - 1], p[f].first);
  }
  if (mi == 1) {
    printf("YES\n");
    printf("%d\n", p[f].first);
    return 0;
  }
  mi = 1;
  for (int i = 0; i < (int)v[p[f].second].size(); i++) {
    dfs(v[p[f].second][i], a[v[p[f].second][i] - 1], p[f].second);
  }
  if (mi == 1) {
    printf("YES\n");
    printf("%d\n", p[f].second);
  } else {
    printf("NO\n");
  }
}
