#include <bits/stdc++.h>
using namespace std;
const long long MX = 5e6 + 9;
const int MAXN = 10100;
const long double pi = acos(-1);
const long long mod = 1e9 + 7;
long long po(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  long long x = po(a, b / 2);
  x *= x % mod;
  if (b % 2) {
    x *= a % mod;
  }
  return x % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else {
    gcd(b, a % b);
  }
}
bool cmp(int a, int b) { return (a > b); }
int dx[] = {0, 0, -1, 1, 1, -1, -1, 1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
vector<int> v[MX];
vector<pair<int, int> > edge, ans;
int c[MX];
int cnt[MX];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
    edge.push_back(make_pair(a, b));
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    cnt[c[i]]++;
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    mx = max(mx, cnt[c[i]]);
  }
  if (mx == n) {
    cout << "YES" << endl << 1;
    return 0;
  }
  memset(cnt, 0, sizeof(cnt));
  int temp = 0;
  for (int i = 0; i < n - 1; i++) {
    pair<int, int> q = edge[i];
    if (c[edge[i].first] != c[edge[i].second]) {
      temp++;
      ans.push_back(q);
      cnt[edge[i].first]++;
      cnt[edge[i].second]++;
    }
  }
  int id = -1;
  mx = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > mx) {
      mx = cnt[i];
      id = i;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i].first != id && ans[i].second != id) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << endl << id;
  return 0;
}
