#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int p[N], c[N];
pair<int, int> ej[N];
vector<int> G[N];
int dfs(int u) {
  for (int i = 0; i < G[u].size(); i++) {
    if (G[u][i] == p[u]) continue;
    p[G[u][i]] = u;
    int cur = dfs(G[u][i]);
    if (cur == -1 || cur != c[u]) return -1;
  }
  return c[u];
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    ej[i] = pair<int, int>(a, b);
  }
  for (int i = 1; i <= n; i++) cin >> c[i];
  int x = -1, y;
  for (int i = 0; i < n - 1; i++)
    if (c[ej[i].first] != c[ej[i].second]) {
      x = ej[i].first;
      y = ej[i].second;
      break;
    }
  if (x == -1) {
    cout << "YES" << endl << "1" << endl;
    return 0;
  }
  bool ans = 1;
  p[x] = -1;
  for (int i = 0; i < G[x].size(); i++) {
    p[G[x][i]] = x;
    if (dfs(G[x][i]) == -1) {
      ans = 0;
      break;
    }
  }
  if (ans) {
    cout << "YES" << endl << x << endl;
    return 0;
  }
  p[y] = -1;
  ans = 1;
  for (int i = 0; i < G[y].size(); i++) {
    p[G[y][i]] = y;
    if (dfs(G[y][i]) == -1) {
      ans = 0;
      break;
    }
  }
  if (ans)
    cout << "YES" << endl << y << endl;
  else
    cout << "NO" << endl;
  return 0;
}
