Given a connected graph with

nodes indexed from

to

and

undirected edges. The
nodes with index

has a value

. We call a path
beautiful if and only if all
nodes in it are distinct and the values of the
nodes are strictly rise from one end to the other.
Find the length of the longest
beautiful path, and print it out.
输入描述:
The first line contains a positive integer
, indicates the number of the vertices.
Each of the next
lines contains two integers
, representing an edge between
and
.
The next line contains
integers
— the array
.
输出描述:
The only line contains ONE integer indicates the length of the longest beautiful path.