func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class U, class V>   ostream& operator<<(ostream& os, const pair<U, V>& p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   template <class U, class V>   istream& operator>>(istream& in, pair<U, V>& p) {     in >> p.first >> p.second;     return in;   }   vector<vector<long long> > al;   long long n;   bool bfs(long long s, long long fr, long long* col) {     bool mark[n];     memset(mark, 0, sizeof(mark));     ;     mark[s] = 1;     queue<long long> q;     for (long long v : al[s]) {       if (v != fr) {         q.push(v);       }     }     while (!q.empty()) {       long long u = q.front();       q.pop();       if (col[u] != col[s]) {         return false;       }       mark[u] = 1;       for (long long v : al[u]) {         if (!mark[v]) {           q.push(v);           mark[v] = 1;         }       }     }     return true;   }   int main() {     scanf( %lld , &n);     ;     al = vector<vector<long long> >(n);     long long c[n];     vector<pair<long long, long long> > inp;     for (long long i = 0; i < n - 1; i++) {       long long u, v;       scanf( %lld %lld , &u, &v);       ;       u--, v--;       al[u].push_back(v);       al[v].push_back(u);       inp.push_back(make_pair(u, v));     }     for (long long i = 0; i < n; i++) {       scanf( %lld , &c[i]);       ;     }     for (auto& e : inp) {       if (c[e.first] != c[e.second]) {         bool f = 0;         for (long long v : al[e.first]) {           if (!bfs(v, e.first, c)) {             f = 1;             break;           }         }         if (!f) {           puts( YES );           printf( %lld n , e.first + 1);           ;           return 0;         }         for (long long v : al[e.second]) {           if (!bfs(v, e.second, c)) {             puts( NO );             return 0;           }         }         puts( YES );         printf( %lld n , e.second + 1);         ;         return 0;       }     }     puts( YES );     printf( %lld n , (long long)1);     ;     return 0;   }   