#include <bits/stdc++.h>
using namespace std;
void Emsawy() {}
int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};
long long suf(long long x) { return max(0LL, (x * (x + 1)) / 2); }
vector<vector<int> > adj;
const long long mod = 1e9 + 7, oo = 1e9;
int n, m, u, v, col[100005];
int get(int nd, int c, int last = -1) {
  if (col[nd] != c) return nd;
  int ret = 0;
  for (int i = 0; i < adj[nd].size(); i++) {
    if (last == adj[nd][i]) continue;
    if (ret = get(adj[nd][i], c, nd)) return ret;
  }
  return 0;
}
int node;
bool valid(int nd, int c, int last = -1) {
  if (nd == node) return 0;
  if (col[nd] != c) return 1;
  int ret = 0;
  for (int i = 0; i < adj[nd].size(); i++) {
    if (last == adj[nd][i]) continue;
    if (ret = valid(adj[nd][i], c, nd)) return ret;
  }
  return 0;
}
int main() {
  Emsawy();
  while (cin >> n) {
    adj.resize(n + 1);
    for (int i = 0; i < n - 1; i++) {
      scanf("%d %d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    set<int> st;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &col[i]);
      st.insert(col[i]);
    }
    if (st.size() == 1) {
      cout << "YES" << endl;
      cout << 1 << endl;
      continue;
    }
    int c = col[1];
    vector<int> ans;
    ans.push_back(get(1, c));
    for (int i = 1; i <= n; i++) {
      if (col[i] != c) {
        ans.push_back(get(i, col[i]));
        break;
      }
    }
    int done = 1;
    for (int i = 0; i < ans.size(); i++) {
      node = ans[i];
      bool ok = 0;
      for (int j = 0; j < adj[node].size(); j++) {
        ok |= valid(adj[node][j], col[adj[node][j]]);
        if (ok) break;
      }
      if (!ok) {
        cout << "YES" << endl;
        cout << node << endl;
        done = 0;
        break;
      }
    }
    if (done) cout << "NO" << endl;
    adj.clear();
  }
  return 0;
}
