import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

int N;
int[] colors;
int[][] adj;


void main() {
    N = readln.chomp.to!int;
    adj = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int).array;
        adj[s[0]-1] ~= s[1]-1;
        adj[s[1]-1] ~= s[0]-1;
    }
    colors = readln.split.map!(to!int).array;

    int[int] cnt;
    foreach (c; colors) {
        if (c in cnt) cnt[c]++;
        else cnt[c] = 1;
    }

    if (cnt.keys.length == 1) {
        writeln("YES");
        writeln(1);
    }
    else {
        Tuple!(int, int)[] borders;
        foreach (i; 0..N) {
            foreach (j; adj[i]) {
                if (colors[i] != colors[j]) {
                    borders ~= tuple(i, j);
                }
            }
        }

        foreach (a; borders[0]) {
            bool flag = true;
            foreach (b; borders) {
                if (a != b[0] && a != b[1]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                writeln("YES");
                writeln(a+1);
                return;
            }
        }

        writeln("NO");
    }
}
