Each New Year Timofey and his friends cut down a tree of *n* vertices and bring it home. After that they paint all the *n* its vertices, so that the *i*-th vertex gets color *c*<sub class="lower-index">*i*</sub>.

Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex in hands, while all the other vertices move down so that the tree becomes rooted at the chosen vertex. After that Timofey brings the tree to a trash can.

Timofey doesn't like it when many colors are mixing together. A subtree annoys him if there are vertices of different color in it. Timofey wants to find a vertex which he should take in hands so that there are no subtrees that annoy him. He doesn't consider the whole tree as a subtree since he can't see the color of the root vertex.

A subtree of some vertex is a subgraph containing that vertex and all its descendants.

Your task is to determine if there is a vertex, taking which in hands Timofey wouldn't be annoyed.
The first line contains single integer *n* (2 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the number of vertices in the tree.

Each of the next *n* - 1 lines contains two integers *u* and *v* (1 ≤ *u*, *v* ≤ *n*, *u* ≠ *v*), denoting there is an edge between vertices *u* and *v*. It is guaranteed that the given graph is a tree.

The next line contains *n* integers *c*<sub class="lower-index">1</sub>, *c*<sub class="lower-index">2</sub>, ..., *c*<sub class="lower-index">*n*</sub> (1 ≤ *c*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>), denoting the colors of the vertices.
none
4
1 2
2 3
3 4
1 2 1 1
YES
2
3
1 2
2 3
1 2 3
YES
2
4
1 2
2 3
3 4
1 2 1 2
NO
3
2 1
2 3
1 2 3
YES
2
4
1 2
2 4
4 3
1 1 3 2
YES
4
2
1 2
1 1
YES
1
10
5 7
4 5
10 2
3 6
1 2
3 4
8 5
4 9
2 3
15 15 15 15 5 15 26 18 15 15
YES
5
8
1 2
1 3
3 5
3 6
1 4
4 7
4 8
1 3 1 1 1 1 1 2
NO
3
2 1
2 3
4 4 4
YES
1
3
1 2
1 3
1 2 2
YES
1
4
1 4
2 4
3 4
1 2 3 1
YES
4
4
1 2
1 3
1 4
1 2 3 4
YES
1
9
1 2
2 3
3 4
4 5
2 7
7 6
2 8
8 9
1 1 2 2 2 3 3 4 4
YES
2
3
2 1
2 3
4 4 5
YES
2
4
1 2
2 3
3 4
1 2 2 1
NO
import math,sys,bisect,heapq,os
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
from functools import lru_cache
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
def input(): return sys.stdin.readline().rstrip('\r\n')
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
aj = lambda: list(map(int, input().split()))
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
#MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

def solve():
		G = defaultdict(list)
	
		def addEdge(a,b):
			G[a].append(b)
			G[b].append(a)
	
		def dfs(node,p):
			d = deque()
			d.append(node)
			vis[node] = True
			while d:
				x = d.pop()
				for i in G.get(x,[]):
					if not vis[i] and i != p:
						vis[i] = True
						d.append(i)
						if C[node-1] != C[i-1]:
							return False
			return True
	
		n, =aj()
		m = n-1
		vis = [False]*(n+1)
		edges = set()
		for i in range(m):
		    u,v = aj()
		    addEdge(u,v)
		    edges.add((u,v))
		C = aj()
		if len(set(C)) == 1:
			Y(1)
			print(1)
			exit(0)
		u=v = None
		for i,j in edges:
			if C[i-1] != C[j-1]:
				u = i
				v = j
				break
		vis = [False]*(n+1)
		if all([dfs(i,u) for i in G.get(u,[])]):
			Y(1)
			print(u)
			exit(0)
		vis = [False]*(n+1)
		if all([dfs(i,v) for i in G.get(v,[])]):
			Y(1)
			print(v)
			exit(0)
		Y(0)






try:
	#os.system("online_judge.py")
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass

solve()