#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
bool vis[100005];
int col[100005];
int cc[100005];
bool bfs(int n) {
  vis[n] = 1;
  for (int i = 0; i < v[n].size(); i++) {
    if (vis[v[n][i]]) continue;
    if (col[n] != col[v[n][i]]) {
      return false;
    }
    if (!bfs(v[n][i])) return false;
  }
  return true;
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int c = 0;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
    if (cc[col[i]] == 0) c++;
    cc[col[i]]++;
  }
  if (c == 1) {
    cout << "YES" << endl;
    cout << 1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (col[i] != col[v[i][j]]) {
        x = 0;
        y = 0;
        vis[i] = 1;
        for (int k = 0; k < v[i].size(); k++) {
          if (bfs(v[i][k]) == false) {
            x = 1;
            break;
          }
        }
        if (x == 0) {
          cout << "YES" << endl;
          cout << i;
          return 0;
        }
        memset(vis, 0, sizeof(vis));
        i = v[i][j];
        vis[i] = 1;
        for (int k = 0; k < v[i].size(); k++) {
          if (bfs(v[i][k]) == false) {
            y = 1;
            break;
          } else
            y = 0;
        }
        if (y == 0) {
          cout << "YES" << endl;
          cout << i;
          return 0;
        } else {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "NO";
}
