#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
vector<vector<long long int> > v;
vector<long long int> c;
long long int r2 = -1;
bool dfsr(long long int u, long long int p, long long int col) {
  if (c[u] != col) return false;
  bool ret = true;
  for (long long int i : v[u])
    if (i != p) ret = ret && dfsr(i, u, col);
  return ret;
}
long long int dfs(long long int u, long long int p) {
  if (c[u] != c[0]) {
    r2 = p;
    return u;
  }
  long long int temp;
  for (long long int i : v[u])
    if (i != p) {
      temp = dfs(i, u);
      if (temp != -1) return temp;
    }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  v.resize(n);
  c.resize(n);
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x - 1].push_back(y - 1);
    v[y - 1].push_back(x - 1);
  }
  for (long long int i = 0; i < n; i++) cin >> c[i];
  bool isr = true;
  for (long long int i : v[0]) isr = isr && dfsr(i, 0, c[i]);
  if (isr) {
    cout << "YES" << endl << 1;
    return 0;
  }
  long long int root = dfs(0, -1);
  if (root == -1) cout << "NO";
  isr = true;
  for (long long int i : v[root]) isr = isr && dfsr(i, root, c[i]);
  if (isr)
    cout << "YES" << endl << root + 1;
  else {
    isr = true;
    for (long long int i : v[r2]) isr = isr && dfsr(i, r2, c[i]);
    if (isr)
      cout << "YES" << endl << r2 + 1;
    else
      cout << "NO";
  }
  return 0;
}
