#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const ll oo = LLONG_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readl(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printl(v) for (auto it : v) printf("%lld ", it); puts("");
int n;
vector<vector<int>>g(N);
vector<int>c(N);
bool oki = false;
void DFS(int u, int p, int root) {
for (auto& v : g[u]) {
if (v == p)
continue;
if (u != root && c[v] != c[u]) {
oki = true;
return;
}
DFS(v, u, root);
}
}
void init() {
oki = false;
for (int i = 0; i <= n; i++)
g[i].clear(), c[i] = 0;
}
void solve() {
scanf("%d", &n);
init();
for (int i = 0; i < n - 1; i++) {
int u, v;
scanf("%d %d", &u, &v);
u--, v--;
g[u].push_back(v);
g[v].push_back(u);
}
for (int i = 0; i < n; i++)
scanf("%d", &c[i]);
vector<int>roots;
for (int u = 0; u < n; u++) {
for (auto& v : g[u]) {
if (c[u] != c[v]) {
roots.push_back(u);
roots.push_back(v);
break;
}
}
if (!roots.empty())
break;
}
if (roots.empty()) {
printf("YES\n1\n");
return;
}
for (auto& it : roots) {
oki = false;
DFS(it, -1, it);
if (!oki) {
printf("YES\n%d\n", it + 1);
return;
}
}
puts("NO");
}
int t = 1;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//scanf("%d", &t);
while (t--) solve();
}
77u/I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVk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