#include <bits/stdc++.h>
using namespace std;
int n, arr[100005];
bool good;
int x[100005], y[100005];
vector<int> v[100005];
int ketua;
void dfs(int skg, int PREV) {
  if (ketua != arr[skg]) {
    good = false;
    return;
  }
  for (auto isi : v[skg]) {
    if (isi != PREV) dfs(isi, skg);
  }
}
bool solve(int x) {
  for (auto isi : v[x]) {
    good = true;
    ketua = arr[isi];
    dfs(isi, x);
    if (good == false) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x[i] >> y[i];
    v[x[i]].push_back(y[i]);
    v[y[i]].push_back(x[i]);
  }
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int root1 = -1, root2 = -1;
  for (int i = 1; i < n; i++) {
    if (arr[x[i]] != arr[y[i]]) {
      root1 = x[i];
      root2 = y[i];
    }
  }
  if (root1 == -1) {
    cout << "YES" << endl;
    cout << 1 << endl;
  } else {
    if (solve(root1)) {
      cout << "YES" << endl;
      cout << root1 << endl;
    } else if (solve(root2)) {
      cout << "YES" << endl;
      cout << root2 << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
