#include <bits/stdc++.h>
using namespace std;
using namespace std;
int N;
vector<pair<int, int> > edges;
vector<pair<int, int> > wrong_edges;
std::vector<int> color;
vector<int> adj[200000];
bool visited[200000]{};
bool dfs(int node, int col) {
  for (auto i : adj[node]) {
    if (visited[i]) {
      continue;
    }
    visited[i] = true;
    if (col != color[i]) {
      return false;
    }
    bool check = dfs(i, col);
    if (!check) return false;
  }
  return true;
}
bool check_ans(int node) {
  visited[node] = true;
  for (int i = 0; i < N; i++) {
    if (visited[i]) continue;
    bool check = dfs(i, color[i]);
    if (!check) {
      return false;
    }
  }
  return true;
}
int main(int nargs, char **argv) {
  cin >> N;
  for (int i = 0; i < N - 1; ++i) {
    int x, y;
    cin >> x;
    cin >> y;
    x = x - 1;
    y = y - 1;
    edges.push_back({x, y});
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 0; i < N; ++i) {
    int c;
    cin >> c;
    color.push_back(c);
  }
  for (auto e : edges) {
    if (color[e.first] != color[e.second]) {
      wrong_edges.push_back(e);
    }
  }
  int ans = 0;
  if (wrong_edges.size() == 0) {
    ans = 0;
  } else if (wrong_edges.size() == 1) {
    ans = wrong_edges[0].first;
  } else {
    pair<int, int> e1 = wrong_edges[0];
    pair<int, int> e2 = wrong_edges[1];
    if (e1.first == e2.first) {
      ans = e1.first;
    } else if (e1.first == e2.second) {
      ans = e1.first;
    } else {
      ans = e1.second;
    }
    if (!check_ans(ans)) {
      ans = -1;
    }
  }
  if (ans >= 0) {
    cout << "YES" << endl;
    cout << (ans + 1) << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
