#include <bits/stdc++.h>
const int N = 100009;
using namespace std;
int n;
vector<vector<int>> adj;
int color[N];
map<pair<int, int>, int> states;
set<pair<int, int>> visited;
int try_node(int idx, int prev) {
  pair<int, int> state = {idx, prev};
  if (visited.count(state)) return states[state];
  visited.insert(state);
  states[state] = 1;
  for (auto ch : adj[idx]) {
    if (ch == prev) continue;
    if (prev != -1 && color[ch] != color[idx]) return states[state] = 0;
    states[state] *= try_node(ch, idx);
  }
  return states[state];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  int node;
  adj.resize(n, vector<int>());
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    node = x;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    cin >> color[i];
  }
  for (int i = 0; i < n; i++) {
    try_node(i, -1);
    pair<int, int> state = {i, -1};
    if (states[state] == 1) {
      cout << "YES\n" << (i + 1);
      return 0;
    }
  }
  cout << "NO" << endl;
}
