#include <bits/stdc++.h>
using namespace std;
long long int color[100005];
class Graph {
  long long int V;
  list<long long int> *adj;

 public:
  Graph(long long int V);
  void addEdge(long long int v, long long int w);
  void BFS(long long int s);
};
Graph::Graph(long long int V) {
  this->V = V;
  adj = new list<long long int>[V];
}
void Graph::addEdge(long long int v, long long int w) {
  adj[v].push_back(w);
  adj[w].push_back(v);
}
void Graph::BFS(long long int s) {
  long long misset[3] = {-1}, answer = 0, index = 0, flag = 0, rooti = -1;
  long long int mismatch = 0;
  bool *visited = new bool[V + 1];
  for (long long int i = 1; i <= V; i++) visited[i] = false;
  list<long long int> queue;
  visited[s] = true;
  queue.push_back(s);
  list<long long int>::iterator i;
  while (!queue.empty()) {
    s = queue.front();
    queue.pop_front();
    for (i = adj[s].begin(); i != adj[s].end(); ++i) {
      if (!visited[*i]) {
        if (color[s] != color[*i] && index == 0) {
          mismatch++;
          misset[index++] = s;
          misset[index++] = *i;
        } else if (color[s] != color[*i]) {
          mismatch++;
          if (rooti == -1) {
            if (misset[0] == s || misset[1] == s)
              answer = s;
            else if (misset[0] == *i || misset[1] == *i)
              answer = *i;
            else {
              flag = 1;
              cout << "NO";
              break;
            }
            rooti = answer;
          } else if (rooti != s && rooti != *i) {
            flag = 1;
            cout << "NO";
            break;
          }
        }
        visited[*i] = true;
        queue.push_back(*i);
      }
    }
    if (flag == 1) break;
  }
  long long int count = 0;
  if (mismatch == 0)
    cout << "YES\n"
         << "1";
  if (flag == 0 && mismatch > 1) {
    cout << "YES\n";
    cout << rooti;
  } else if (flag == 0 && mismatch == 1) {
    for (long long int i = 1; i < V; i++) {
      if (misset[0] == color[i]) count++;
      if (count > 1) {
        cout << "YES\n" << misset[1];
        return;
      }
    }
    cout << "YES\n" << misset[0];
  }
}
int main() {
  long long int n, u, v, i, c;
  cin >> n;
  Graph g(n + 1);
  for (i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    g.addEdge(u, v);
  }
  for (i = 1; i <= n; i++) {
    cin >> c;
    color[i] = c;
  }
  g.BFS(1);
  return 0;
}
