#include <bits/stdc++.h>   using namespace std;   vector<int> c;   vector<bool> used;   void dfs(int u, vector<vector<int>>& v) {     used[u] = 1;     for (int i = 0; i < v[u].size(); i++) {       if (c[u] == c[v[u][i]] && !used[v[u][i]]) {         dfs(v[u][i], v);       }     }   }   int main() {     int n;     cin >> n;     vector<vector<int>> v(n);     c.resize(n);     used.resize(n, 0);     vector<int> cnt(110000);     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       v[a].push_back(b);       v[b].push_back(a);     }     for (int i = 0; i < n; i++) {       cin >> c[i];     }     for (int i = 0; i < n; i++) {       if (!used[i]) {         cnt[c[i]]++;         dfs(i, v);       }     }     multiset<int> data;     for (int i = 0; i < 100010; i++) {       for (int j = 0; j < cnt[i]; j++) {         data.insert(i);       }     }     for (int i = 0; i < n; i++) {       bool check = 0;       multiset<int> tmp;       for (int j = 0; j < v[i].size(); j++) {         if (c[v[i][j]] == c[i]) {           check = 1;         }         tmp.insert(c[v[i][j]]);       }       if (!check) {         tmp.insert(c[i]);       }       if (tmp == data) {         cout <<  YES  << endl;         cout << i + 1 << endl;         return 0;       }     }     cout <<  NO  << endl;   }   