func_code_string: #include <bits/stdc++.h>   using namespace std;   unordered_map<long long, vector<long long>> m3;   vector<long long int> v;   long long a;   int dfs(long long i, long long p) {     long long k, k1, j, t;     k = -1;     k1 = 0;     for (j = 0; j < m3[i].size(); j++) {       long long d = m3[i][j];       if (d != p) {         t = dfs(d, i);         if (t == 1) {           if (v[d] != v[i]) {             k1 = -1;           }         } else {           k1 = -1;         }       }     }     if (k1 == 0) {       return 1;     }     return -1;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long i, j, b, n, x, y, z, t, k, sum, sum1;     vector<long long int> v1, v2, v3, v4;     string s, s1, s2;     unordered_map<long long, long long> m1, m2, m7;     unordered_map<long long, vector<long long>> m;     t = 1;     while (t--) {       cin >> n;       for (i = 0; i < n - 1; i++) {         cin >> a >> b;         m3[a].push_back(b);         m3[b].push_back(a);       }       a = 0;       v.push_back(0);       for (i = 0; i < n; i++) {         cin >> j;         v.push_back(j);       }       j = 1;       x = -1;       for (i = 1; i <= n; i++) {         for (k = 0; k < m3[i].size(); k++) {           if (v[i] != v[m3[i][k]]) {             x = i;             y = m3[i][k];             break;           }         }       }       if (x == -1) {         cout <<  YES  << endl;         cout << 1;         return 0;       }       for (j = 0; j < m3[x].size(); j++) {         i = dfs(m3[x][j], x);         if (i == -1) break;       }       if (i == 1) {         cout <<  YES  << endl;         cout << x;         return 0;       }       x = y;       for (j = 0; j < m3[x].size(); j++) {         i = dfs(m3[x][j], x);         if (i == -1) break;       }       if (i == 1) {         cout <<  YES  << endl;         cout << y;         return 0;       }       cout <<  NO  << endl;     }   }   