#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int INF = 1000000000;
const int BS = 1000000000 + 7;
const long long INFLL = 1000000000ll * 1000000000ll;
int a[NMAX];
vector<int> e[NMAX];
int c[NMAX];
bool cwas[NMAX];
vector<int> adjVertices;
void dfs(int u, int p, int col) {
  for (vector<int>::iterator it = e[u].begin(); it != e[u].end(); it++) {
    if (*it == p) continue;
    if (c[*it] == col) {
      dfs(*it, u, col);
    } else {
      adjVertices.push_back(*it);
    }
  }
}
void ret(int u) {
  if (-1 == u) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    cout << u << endl;
  }
  exit(0);
}
bool check(int u, int p, int col) {
  bool res = true;
  for (vector<int>::iterator it = e[u].begin(); it != e[u].end(); it++) {
    if (*it == p) continue;
    if (c[*it] == col) {
      res &= check(*it, u, col);
    } else {
      return false;
    }
  }
  return res;
}
bool checkRoot(int u) {
  bool res = true;
  for (vector<int>::iterator it = e[u].begin(); it != e[u].end(); it++) {
    res &= check(*it, u, c[*it]);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  int root = 1;
  vector<int> maybeRoot;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (vector<int>::iterator it = e[i].begin(); it != e[i].end(); it++) {
      cnt += (c[*it] != c[i]) ? 1 : 0;
    }
    if (cnt == 1) {
      maybeRoot.push_back(i);
    }
    if (cnt > 1) {
      root = i;
    }
  }
  if (checkRoot(root)) {
    ret(root);
  } else {
    if (maybeRoot.size() > 2) {
      ret(-1);
    }
    for (vector<int>::iterator it = maybeRoot.begin(); it != maybeRoot.end();
         it++) {
      if (checkRoot(*it)) {
        ret(*it);
      }
    }
    ret(-1);
  }
  return 0;
}
