#include <bits/stdc++.h>
using namespace std;
void dfscc(vector<int> colgraph[], bool visited[], int node) {
  visited[node] = true;
  for (auto itr : colgraph[node]) {
    if (!visited[itr]) {
      dfscc(colgraph, visited, itr);
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> colgraph[n + 1];
  pair<int, int> pii[n + 1];
  for (int i = 1; i < n; i++) {
    cin >> pii[i].first >> pii[i].second;
  }
  int colors[n + 1], coldeg[n + 1];
  ;
  set<int> col;
  for (int i = 1; i <= n; i++) {
    cin >> colors[i];
    col.insert(colors[i]);
    coldeg[i] = 0;
  }
  for (int i = 1; i < n; i++) {
    if (colors[pii[i].first] == colors[pii[i].second]) {
      colgraph[pii[i].first].push_back(pii[i].second);
      colgraph[pii[i].second].push_back(pii[i].first);
    } else {
      coldeg[pii[i].first]++;
      coldeg[pii[i].second]++;
    }
  }
  int colsize = col.size();
  int ncc = 0;
  bool visited[n + 1];
  memset(visited, false, sizeof(visited));
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      ncc++;
      dfscc(colgraph, visited, i);
    }
  }
  bool answer = false;
  for (int i = 1; i <= n; i++) {
    if (coldeg[i] + 1 == ncc) {
      cout << "YES\n" << i;
      answer = true;
      break;
    }
  }
  if (!answer) {
    cout << "NO";
  }
  return 0;
}
