#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 20;
int n, c[maxx], sz[maxx], rang[maxx], okd[maxx], oku[maxx], t[maxx];
bool vis[maxx], takrang[maxx];
vector<int> adj[maxx];
void dfs(int root) {
  vis[root] = true;
  int tedad = t[c[0]];
  if (c[0] == c[root]) tedad--;
  bool bb = false, payin = true, trb = true;
  for (int x : adj[root]) {
    if (!vis[x]) {
      bb = true;
      dfs(x);
      if (c[0] == c[x]) tedad -= sz[x];
      sz[root] += sz[x];
      if (c[root] != c[x] || !takrang[x]) trb = false;
      if (!takrang[x]) payin = false;
    }
  }
  if (!bb) {
    takrang[root] = true, rang[root] = c[root], okd[root] = true, sz[root] = 1;
    if ((c[root] == c[0] && t[c[0]] == n) ||
        (c[root] != c[0] && t[c[0]] == n - 1))
      oku[root] = true;
    return;
  }
  sz[root]++;
  takrang[root] = trb;
  okd[root] = payin;
  if (root == 0)
    oku[root] = true;
  else if (tedad == n - sz[root])
    oku[root] = true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; i++) cin >> c[i], t[c[i]]++;
  dfs(0);
  for (int i = 0; i < n; i++)
    if (oku[i] && okd[i]) return cout << "YES" << endl << i + 1 << endl, 0;
  cout << "NO" << endl;
  return 0;
}
