#include <bits/stdc++.h>
using namespace std;
int n, c[300500];
pair<int, int> e[300500];
vector<int> g[300500];
int cur = 1;
void dfs(int u, int p = -1) {
  for (int to : g[u]) {
    if (p == -1) {
      dfs(to, u);
    } else {
      if (to == p) {
        continue;
      }
      if (c[to] != c[u]) {
        cur = 0;
      }
      dfs(to, u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    e[i].first = u;
    e[i].second = v;
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i < n; i++) {
    if (c[e[i].first] != c[e[i].second]) {
      bool nice = 0;
      dfs(e[i].first);
      if (cur) {
        cout << "YES\n";
        cout << e[i].first;
        nice = 1;
      }
      cur = 1;
      dfs(e[i].second);
      if (cur && !nice) {
        cout << "YES\n";
        cout << e[i].second;
        nice = 1;
      }
      if (!nice) {
        cout << "NO\n";
      }
      return 0;
    }
  }
  cout << "YES\n";
  cout << 1;
}
