#include <bits/stdc++.h>
using int_t = long long int;
bool dfs(int_t u, int_t color, const std::vector<std::vector<int_t>>& edges,
         const std::vector<int_t>& c, std::vector<bool>& visited) {
  if (c[u] != color) {
    return false;
  }
  for (int_t v : edges[u]) {
    if (!visited[v]) {
      visited[v] = true;
      if (!dfs(v, color, edges, c, visited)) {
        return false;
      }
    }
  }
  return true;
}
bool dfs(int_t u, const std::vector<std::vector<int_t>>& edges,
         const std::vector<int_t>& c) {
  std::vector<bool> visited(edges.size());
  visited[u] = true;
  for (int_t v : edges[u]) {
    visited[v] = true;
    if (!dfs(v, c[v], edges, c, visited)) {
      return false;
    }
  }
  return true;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int_t n;
  std::cin >> n;
  std::vector<std::vector<int_t>> edges(n);
  for (int_t i = 0; i < n - 1; ++i) {
    int_t u;
    int_t v;
    std::cin >> u >> v;
    --u;
    --v;
    edges[u].emplace_back(v);
    edges[v].emplace_back(u);
  }
  std::vector<int_t> c(n);
  for (int_t& ci : c) {
    std::cin >> ci;
  }
  bool found = false;
  for (int_t u = 0; u < n; ++u) {
    for (int_t v : edges[u]) {
      if (c[u] != c[v]) {
        found = true;
        if (dfs(u, edges, c)) {
          std::cout << "YES" << '\n';
          std::cout << u + 1 << '\n';
          return 0;
        }
        if (dfs(v, edges, c)) {
          std::cout << "YES" << '\n';
          std::cout << v + 1 << '\n';
          return 0;
        }
        break;
      }
    }
    if (found) {
      break;
    }
  }
  if (found) {
    std::cout << "NO" << '\n';
  } else {
    std::cout << "YES" << '\n';
    std::cout << 1 << '\n';
  }
  return 0;
}
