#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> g;
vector<vector<int>> m;
vector<int> c;
bool poss(int n, int p, int col) {
  if (col == -1)
    col = c[n];
  else if (c[n] != col)
    return false;
  if (m[n][p] != -1) {
    return m[n][p] == col;
  }
  for (int x = 0; x < g[n].size(); x++) {
    if (x != p)
      if (!poss(g[n][x].first, g[n][x].second, col)) return m[n][p] = false;
  }
  return m[n][p] = col;
}
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  g.assign(N + 1, vector<pair<int, int>>());
  m.assign(N + 1, vector<int>());
  int A, B;
  for (int n = 1; n < N; n++) {
    cin >> A >> B;
    g[A].push_back({B, g[B].size()});
    g[B].push_back({A, g[A].size() - 1});
    m[A].push_back(-1);
    m[B].push_back(-1);
  }
  c.assign(N + 1, 0);
  for (int x = 1; x <= N; x++) cin >> c[x];
  for (int x = 1; x <= N; x++) {
    bool p = true;
    for (int y = 0; y < g[x].size(); y++) {
      if (!poss(g[x][y].first, g[x][y].second, -1)) {
        p = false;
      }
    }
    if (p) {
      cout << "YES" << endl << x << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
