#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
vector<int> c;
bool dfs(int u, int parent) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == parent) {
      continue;
    }
    if (c[v] != c[u]) {
      return false;
    }
    if (dfs(v, u) == false) {
      return false;
    }
  }
  return true;
}
int main(int argc, char **argv) {
  int n;
  scanf("%d", &n);
  adj = vector<vector<int> >(n);
  c = vector<int>(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bool same = true;
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    if (i > 0 && c[i] != c[i - 1]) {
      same = false;
    }
  }
  if (same) {
    puts("YES");
    puts("1");
    return 0;
  }
  int root = -1;
  for (int u = 0; u < n; u++) {
    int cnt = 0;
    root = -1;
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (c[v] != c[u]) {
        cnt++;
        root = v;
      }
    }
    if (cnt == 1) {
      break;
    }
  }
  if (root == -1) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < adj[root].size(); i++) {
    int u = adj[root][i];
    if (dfs(u, root) == false) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  printf("%d\n", root + 1);
  return 0;
}
