#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int N3 = 1e3 + 10;
const int INF = 2e9 + 10;
const int mod = 1e9 + 7;
const long long LINF = 4e18 + 10;
int n, c[N], col[N], sz[N], cnt, ans, sans, syes, usedcol[N];
vector<int> v[N];
bool u[N];
pair<int, int> p[N];
map<pair<int, int>, bool> used;
void dfs(int x) {
  u[x] = 1;
  col[x] = cnt;
  for (int i = 0; i < v[x].size(); ++i) {
    int to = v[x][i];
    if (!u[to] && c[x] == c[to]) {
      dfs(to);
    }
  }
}
bool fast() {
  for (int i = 1; i <= n; ++i) {
    int temp = 1;
    usedcol[col[i]] = 1;
    for (int j = 0; j < v[i].size(); ++j) {
      int to = v[i][j];
      if (!usedcol[col[to]]) {
        temp++;
        usedcol[col[to]] = 1;
      }
    }
    if (temp == cnt) {
      ans = i;
      return 1;
    }
    for (int j = 0; j < v[i].size(); ++j) {
      int to = v[i][j];
      usedcol[col[to]] = 0;
    }
    usedcol[col[i]] = 0;
  }
  return 0;
}
int main() {
  if ("" != "") {
    freopen(
        ""
        ".in",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    u[i] = 0;
  }
  cnt = 0;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    p[i] = make_pair(x, y);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (!u[i]) {
      cnt++;
      dfs(i);
    }
  }
  for (int i = 1; i <= cnt; ++i) {
    usedcol[i] = 0;
  }
  bool res = fast();
  if (!res) {
    cout << "NO";
  } else {
    cout << "YES\n";
    cout << ans;
  }
  return 0;
}
