#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 100005;
vector<int> edge[N];
int n;
int c[N];
int ans;
bool vis[N];
int is[N];
bool ok[N];
bool dfs(int u) {
  vis[u] = true;
  int len = edge[u].size();
  bool flag = true;
  for (int i = 0; i < len; ++i) {
    int v = edge[u][i];
    if (!vis[v]) {
      if (!dfs(v))
        flag = false;
      else {
        if (is[v] != -1 && is[v] != c[v])
          flag = false;
        else if (is[u] == -1)
          is[u] = c[v];
        else if (is[u] != c[v])
          flag = false;
      }
    }
  }
  if (flag == false) return false;
  ok[u] = true;
  return true;
}
bool dfs2(int fa, int u) {
  vis[u] = true;
  int len = edge[u].size();
  int k = 0;
  int p = -1;
  for (int i = 0; i < len; ++i) {
    int v = edge[u][i];
    if (vis[v]) continue;
    if (!ok[v] || (is[v] != -1 && is[v] != c[v])) {
      if (p == -1)
        p = v;
      else
        return false;
    }
  }
  if (p != -1) {
    if (fa == -1 || fa == c[u]) {
      for (int j = 0; j < len; ++j) {
        int v = edge[u][j];
        if (vis[v] || v == p) continue;
        if (c[v] != c[u]) return false;
      }
      dfs2(c[u], p);
    } else
      return false;
  } else {
    ans = u;
    return true;
  }
}
bool solve() {
  ans = -1;
  dfs(1);
  memset(vis, false, sizeof(vis));
  dfs2(-1, 1);
  if (ans == -1) return false;
  return true;
}
void init() {
  for (int i = 1; i <= n; ++i) edge[i].clear();
}
void add_edge(int u, int v) {
  edge[u].push_back(v);
  edge[v].push_back(u);
  memset(vis, false, sizeof(vis));
  memset(is, -1, sizeof(is));
  memset(ok, false, sizeof(ok));
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u, v);
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
  if (solve())
    printf("YES\n%d\n", ans);
  else
    printf("NO\n");
  return 0;
}
