#include <bits/stdc++.h>   using namespace std;   vector<int> v[100001];   int n, cost[100001];   int gr, nod, gr2;   void DFS(int x, int t, int val) {     for (int i = 1; i <= v[x][0]; i++) {       if (v[x][i] != t) {         if (val == 0) {           DFS(v[x][i], x, cost[v[x][i]]);         } else {           if (val != cost[v[x][i]]) {             gr++;             if (nod != x) gr2++;             nod = x;           }           DFS(v[x][i], x, cost[v[x][i]]);         }       }     }   }   int main() {     int a, b, i, j;     cin >> n;     for (i = 1; i <= n; i++) {       v[i].push_back(0);     }     for (i = 1; i < n; i++) {       cin >> a >> b;       v[a][0]++;       v[b][0]++;       v[a].push_back(b);       v[b].push_back(a);     }     for (i = 1; i <= n; i++) cin >> cost[i];     DFS(1, 0, 0);     if (gr2 <= 2) {       if (gr == 0) {         cout <<  YES               <<   n               << 1;       } else {         gr = 0;         DFS(nod, 0, 0);         if (gr != 0) {           cout <<  NO ;         } else {           cout <<  YES ;           cout <<   n  << nod;         }       }     } else {       cout <<  NO ;     }     return 0;   }   