#include <bits/stdc++.h>
using namespace std;
const long long M = 1e6 + 10, MOD = 100000000000;
vector<int> v[200000];
int color[200000];
int p, qq;
bool vis[200000];
bool dfs(int s) {
  vis[s] = 1;
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < v[x].size(); i++) {
      int y = v[x][i];
      if (!vis[y]) {
        vis[y] = 1;
        q.push(y);
        if (color[y] != color[x]) {
          return 0;
        }
      }
    }
  }
  return 1;
}
void bfs(int s) {
  vis[s] = 1;
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < v[x].size(); i++) {
      int y = v[x][i];
      if (!vis[y]) {
        vis[y] = 1;
        q.push(y);
        if (color[y] != color[x]) {
          p = x;
          qq = y;
          return;
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) cin >> color[i];
  int idx = 1;
  bfs(1);
  if (!p) {
    cout << "YES\n";
    cout << idx << "\n";
    return 0;
  }
  if (p) {
    for (int i = 1; i <= n; i++) vis[i] = 0;
    bool ok = 1;
    vis[p] = 1;
    for (int i = 1; i <= n; i++) {
      if (i != p && !vis[i]) {
        ok = dfs(i);
        if (!ok) break;
      }
    }
    if (ok) {
      cout << "YES\n";
      cout << p << "\n";
      return 0;
    }
    for (int i = 1; i <= n; i++) vis[i] = 0;
    ok = 1;
    vis[qq] = 1;
    for (int i = 1; i <= n; i++) {
      if (i != qq && !vis[i]) {
        ok = dfs(i);
        if (!ok) break;
      }
    }
    if (ok) {
      cout << "YES\n";
      cout << qq << "\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
