#include <bits/stdc++.h>
using namespace std;
int xd[] = {0, 1, 0, -1};
int yd[] = {1, 0, -1, 0};
int xx[] = {0, 1, 0, -1, 1, -1, 1, -1};
int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};
int kx[] = {-2, -1, -2, -1, 1, 2, 2, 1};
int ky[] = {1, 2, -1, -2, -2, -1, 1, 2};
bool islucky(int x) {
  int four = 0, seven = 0;
  while (x) {
    if (x % 10 != 7 && x % 10 != 4) return false;
    if (x % 10 == 7)
      seven++;
    else
      four++;
    x = x / 10;
  }
  return four == seven;
}
bool is_prime(long long x) {
  if (x == 1) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
long long C(int k, int l) {
  if (l == k) return 1;
  if (l * 2 > k) l = k - l;
  long long res = 1, temp = l;
  for (int i = k - l + 1; i <= k; i++) {
    res *= i / temp;
    temp--;
  }
  return res;
}
long long sumOfDigit(int x) {
  int res = 0;
  while (x) {
    res += x % 10;
    x /= 10;
  }
  return res;
}
uint64_t bigPow(uint64_t base, uint64_t p) {
  uint64_t temp = 1;
  while (p--) {
    temp *= base;
  }
  return temp;
}
vector<int> soso;
bool prime[10000001] = {0};
void SieveOfEratosthenes(int n) {
  soso.push_back(2);
  for (int p = 3; p * p <= n; p += 2) {
    if (prime[p] == false) {
      for (int i = p * 2; i <= n; i += p) prime[i] = true;
    }
  }
  for (int i = 3; i <= n; i += 2)
    if (!prime[i]) soso.push_back(i);
}
bool visited[200000 + 5];
bool flag1 = true, flag2 = true;
vector<vector<int> > adj;
int color[200000 + 5];
void dfs(int s, int cur_color) {
  visited[s] = true;
  for (int i = 0; i < adj[s].size(); i++) {
    if (!visited[adj[s][i]]) {
      if (color[adj[s][i]] == cur_color)
        dfs(adj[s][i], cur_color);
      else
        flag1 = false;
    }
  }
}
int main() {
  int n, from, to;
  cin >> n;
  adj = vector<vector<int> >(n + 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> from >> to;
    adj[from].push_back(to);
    adj[to].push_back(from);
  }
  for (int i = 0; i < n; i++) cin >> color[i + 1];
  int nod1 = -1, nod2 = -1;
  for (int i = 1; i <= n; i++) {
    nod1 = -1, nod2 = -1;
    for (int j = 0; j < adj[i].size(); j++) {
      if (color[i] != color[adj[i][j]]) {
        nod1 = i, nod2 = adj[i][j];
        break;
      }
    }
    if (nod1 != -1) break;
  }
  if (nod1 == -1 && nod2 == -1) {
    cout << "YES" << endl << 1 << endl;
    return 0;
  }
  for (int i = 0; i < adj[nod1].size(); i++) {
    visited[nod1] = true;
    dfs(adj[nod1][i], color[adj[nod1][i]]);
  }
  if (flag1) {
    cout << "YES" << endl << nod1;
    return 0;
  }
  memset(visited, false, sizeof visited);
  flag1 = true;
  for (int i = 0; i < adj[nod2].size(); i++) {
    visited[nod2] = true;
    dfs(adj[nod2][i], color[adj[nod2][i]]);
  }
  if (flag1) {
    cout << "YES" << endl << nod2;
    return 0;
  }
  cout << "NO";
}
